rlang: what is difference between sym,quo function. I have give below examples

my_column <- "age"
my_columns <- c("age", "height", "weight")

my_column1 <- quo(age)
my_columns1 <- quos("age", "height", "weight")

my_data <- data.frame(age = c(20, 30, 40),
height = c(170, 180, 190),
weight = c(60, 70, 80))

Filter the data frame based on a single column

my_filtered_data_1 <- my_data %>%
filter(!!sym(my_column) > 25)
#with quo
my_filtered_data_1 <- my_data %>%
filter(!!my_column1 > 25)

Filter the data frame based on multiple columns

my_filtered_data_2 <- my_data %>%
select(!!!syms(my_columns))
my_filtered_data_2 <- my_data %>%
select(!!!my_columns1)

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.