I am writing a package using a lot of dplyr
functions - to pass on all tests in devtools::check()
, I have to use .data
frequently. Some of the functions are nested into other functions. In the example below, I need to use variable
both in a tidyselect
context and in standard evaluation (in the part that creates id)
.
df <- data.frame(
V1 = 1:8,
V2 = rep(1:4,2)
)
test <- function(df, variable){
x <- df %>%
mutate(y = {{variable}} + 1)
id <- rlang::as_name(rlang::enquo(variable))
id_eq <- outer(df[[id]], df[[id]], `==`)
list(x, id_eq)
}
I don't know how to deal with this without getting any warnings or notes in CMD check.
The function works if I run test(df = df, variable = V1)
, but not with test(df = df, variable = .data$V1)