(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)