|
|
|
|
|
by closed
1296 days ago
|
|
One interesting thing about R examples is their outputs tend to be bigger. I think this is in direct contrast to python docstrings, where outputs are very concise--because you manually include the output for doctest. I wonder if a challenge for doctests in R is they often have to test larger, more realistic outputs? For example, in dplyr's mutate doc, one example is this: starwars %>%
select(name, mass) %>%
mutate(
mass2 = mass * 2,
mass2_squared = mass2 * mass2
)
This example's output is a dataframe with 4 columns and will display first 5 rows.On the other hand in siuba (a port of dplyr to python), I often have to truncate the example output, because it's hard coded in the docstring: (cars
>> mutate(
cyl2 = _.cyl * 2,
cyl4 = _.cyl2 * 2
)
>> head(2)
)
cyl mpg hp cyl2 cyl4
0 6 21.0 110 12 24
1 6 21.0 110 12 24
It's nice you can see the full example in the docstring in python, but also very handy seeing complex examples on R doc pages:https://dplyr.tidyverse.org/reference/mutate.html#ref-exampl... |
|