Cannot use purrr-style lambda function with `select()` (dplyr 1.0.0 dev)

(I'm currently using the development version of dplyr 1.0.0)

With dplyr 1.0.0, the across() should supersede all scoped verbs, and the scoped select_all documentation now says "select_if() and rename_if() already use tidy selection so they can't be replaced by across() and instead we need a new function."

But what about trying to use a purrr-style function with select(), the way we used to with select_if()?

Am I doing this wrong? Thanks in advance!

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

df <- tibble(x = c(1,2,3), y = c(4,5,NA), 
             z = c(NA, NA, NA), a = c("1", "2", "3"))

select(df, is.numeric | contains("a"))
#> # A tibble: 3 x 3
#>       x     y a    
#>   <dbl> <dbl> <chr>
#> 1     1     4 1    
#> 2     2     5 2    
#> 3     3    NA 3

select(df, ~!all(is.na(.)))
#> Error: Must subset columns with a valid subscript vector.
#> x Subscript has the wrong type `formula`.
#> ℹ It must be numeric or character.

select_if(df, ~!all(is.na(.)))
#> # A tibble: 3 x 3
#>       x     y a    
#>   <dbl> <dbl> <chr>
#> 1     1     4 1    
#> 2     2     5 2    
#> 3     3    NA 3

Created on 2020-04-17 by the reprex package (v0.3.0)

Could you please file an issue for this?

1 Like

Sounds good, filed at

Thanks!

3 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.