In the below code, I would like to use a function that reads in an argument as a quosure (i.e. testFun), but do so from another function (i.e. testFun2). In the below, how can I get the output of testFun2("attitude$rating")
to be identical to the output of testfun(attitude$rating)
.
If possible, I prefer to only modify testFun2
and not testFun
. I am having trouble finding the right tidyeval recipe to do this, so any help is very much appreciated. Thanks!!
testFun = function(data = NULL) {
# capture data as quosure
dataQuo = rlang::enquo(data) ##capture as quosure to get env
dataString = ifelse(is.null(data),NA,rlang::quo_name(dataQuo))
return(dataString)
}
testFun2 = function(textString) {
z = testFun(textString)
return(z)
}
### I want the output from testFun2 (below)
### to be identical to the output of testFun (below)
testFun(attitude$rating)
testFun2("attitude$rating")