The question is similar than this one:
Pass a data.frame column name to a function
I have a function:
optimal_cutpoint <- function(data, ..., choice){
selection <- dplyr::select(data, ...)
choice <- data[[choice]]
# do something with those two objects
}
The function I would use the following way:
choicedata <- data.frame(PTV.A = c(0, 10, 5, 4, 7, 1, 2, 0, 0, 10),
PTV.B = c(5, 0, 1, 10, 6, 7, 10, 9, 5, 0),
PTV.C = c(10, 5, 10, 5, 2, 8, 0, 5, 5, 0),
VOTE = c("C", "A", "C", "B", "B", "C", "B","B", "B", "A"))
optimal_cutpoint(choicedata, PTV.A:PTV.C, choice = "VOTE")
Now to my question. With the ... I can write the variable names without quotes. Is there a possibility that I can write the "VOTE" without the quotes? I would prefere to write it without quotes to be consistent in the function.
If I use dplyr::select it searches for choice instead of vote.
dplyr::select(data,choice)