I have a string with the same name as a variable in a tibble. If I want to filter using this string, I have the following working options:
jahr <- 2020
test <- tibble(jahr = c(2019, 2020), fte2020 = c(10, 11), fte2021 = c(12,13))
spalte <- paste0("fte", jahr)
# Using get:
test %>%
filter(base::get(spalte) == 11)
# Using all in one:
test %>%
filter(base::get(paste0("fte", .env$jahr)) == 11)
# Using .data:
test %>%
filter(.data[[spalte]] == 11)
I thought that something like
test %>%
filter( {{ spalte }} == 11)
would also work. But it doesn't. Is this not possible or am I missing something?
Cheers Renger