I am certain this is answered somewhere, but was unable to find it. Programming with dplyr also doesn't give the answer.
I need to pass the name of a variable as a parameter to a function and have the function assign a value to it.
assign_x <- function(xf = x){
xf <- 5
}
rm(x)
assign_x(x)
x
Use Case:
I want to write a wrapper to odbc::dbConnect where I check to see if the connection is already valid and recycle the connection if needed. Sometimes I need to disconnect then reconnect to get the connection to work properly if the query hangs on me.