A wrapper around the select()
function for
selection data frame columns. Supports standard and non standard
evaluations. Usefull to easily program with dplyr
df_select(data, ..., vars = NULL)
a data frame
One or more unquoted expressions (or variable names) separated by commas. Used to select a variable of interest.
a character vector containing the variable names of interest.
a data frame
df <- head(ToothGrowth)
df
#> len supp dose
#> 1 4.2 VC 0.5
#> 2 11.5 VC 0.5
#> 3 7.3 VC 0.5
#> 4 5.8 VC 0.5
#> 5 6.4 VC 0.5
#> 6 10.0 VC 0.5
# Select column using standard evaluation
df %>% df_select(vars = c("dose", "len"))
#> dose len
#> 1 0.5 4.2
#> 2 0.5 11.5
#> 3 0.5 7.3
#> 4 0.5 5.8
#> 5 0.5 6.4
#> 6 0.5 10.0
# Select column using non-standard evaluation
df %>% df_select(dose, len)
#> dose len
#> 1 0.5 4.2
#> 2 0.5 11.5
#> 3 0.5 7.3
#> 4 0.5 5.8
#> 5 0.5 6.4
#> 6 0.5 10.0