I'm using a library that has a function, f. This function accepts a few arguments: an object, a dataframe, and the name of a column in the dataframe. If I call it manually, it works without any trouble. I call it like this:
f(my_object, my_dataframe, 'A')
However, if I put 'A' in a variable, it doesn't work! To clarify, I just do this:
g = 'A'
f(my_object, my_dataframe, g)
And I get an error (undefined columns selected). I've tried googling to figure this out, but no luck. If anyone could help I would really appreciate it.
EDIT: I'm using the partialPlot command in the randomForest library. Here's exactly what I'm typing:
partialPlot(r,x,'pH')
This works! Next, I assign 'pH' to a variable and try the exact same function:
g = 'pH'
partialPlot(r,x,g)
This doesn't work and I get the following error:
Error in '[.data.frame'(pred.data, , xname) : undefined columns selected
I can also verify that g is what I think it is:
print(g)
#[1] "pH"
class(g)
#[1] "character"