1
I try to use the functions filter_ (all, at, if), but unsuccessfully, mainly for strings. Consider the data set below:
set.seed(1234)
data_1 <- data.frame(
a = c(paste('group', 1:6, sep = '_')),
b = c(paste('new', 1:6, sep = '_')),
d = c(rnorm(6, 10, 1))
)
Questions:
How to filter, at once, everything that contains the particle
1? (filter_all)How to filter, at once, all that contains
1and3in the variablesaandb? (filter_at)How to filter, at once, all that contains
1and3in the variablesaandband all that is greater (>) that10in the variabled? (filter_at)How to filter everything that is
character, if it contains the particles1and3? (filter_if)
Little sketch of what I tried:
library(dplyr)
filter_at(data_1, c('a', 'b'), any_vars('1'))
Error: No tidyselect variables Were Registered
I tried to filter the variables a and b, but it didn’t work out.
I never used the function filter with these suffixes, so doubt.
Great. Thank you, Rui.
– neves