WinVector / seplyr

Improved Standard Evaluation Interfaces for Common Data Manipulation Tasks
https://winvector.github.io/seplyr/
Other
49 stars 12 forks source link

rlang section of using_seplyr vignette needs updating #7

Closed TimTaylor closed 3 years ago

TimTaylor commented 3 years ago

It seems like some of the described behaviour in the _usingseplyr vignette (within the rlang/tidyeval section - https://winvector.github.io/seplyr/articles/using_seplyr.html#rlang-tidyeval) contradicts what is shown by the code. As an example - the following appears in the rendered vignette

packageVersion("dplyr")
## [1] '1.0.5'
packageVersion("rlang")
## [1] '0.4.10'
packageVersion("tidyselect")
## [1] '1.1.0'
my_var <- "homeworld"

starwars %>%
  group_by(.data[[my_var]]) %>%
  summarise_at(vars(height:mass), mean, na.rm = TRUE)
## # A tibble: 49 x 3
##    homeworld      height  mass
##    <chr>           <dbl> <dbl>
##  1 Alderaan         176.  64  
##  2 Aleen Minor       79   15  
##  3 Bespin           175   79  
##  4 Bestine IV       180  110  
##  5 Cato Neimoidia   191   90  
##  6 Cerea            198   82  
##  7 Champala         196  NaN  
##  8 Chandrila        150  NaN  
##  9 Concord Dawn     183   79  
## 10 Corellia         175   78.5
## # … with 39 more rows

Notice the created grouping column is called “my_var”, and not “homeworld”. This may seem like a small thing, but it will cause any downstream processing to fail. One can try variations and get many different results, some of which are correct and some of which are not.

Some of the later examples also now contradict themselves when comparing text to code.

JohnMount commented 3 years ago

Sorry about that. I agree that is bad. It is a case of the rlang issue being present when I wrote seplyr (one of the reasons I wrote it). dplyr/rlang semantics have since changed (I did file issues on this at the time). Thanks for filing, I'll try and update the documentation.

JohnMount commented 3 years ago

Thanks again. Fixed with 584fd458f5755946468defee47258d57ef861b56 . CRAN is submissions are closed until September 1, 2021, so I'll update CRAN some time later.

TimTaylor commented 3 years ago

:+1: That was quick!