I have found that to convert a variable name into a string I would use deparse(substitute(x)) where x is my variable name. But what if I want to do this in an sapply function call?
sapply( myDF, function(x) { hist( x, main=VariableNameAsString ) } )
When I use deparse(substitute(x)), I get something like X[[1L]] as the title. I would like to have the actual variable name. Any help would be appreciated.
David
If you need the names, then iterate over the names, not the values:
Alternatively, iterate over both names and values at the same time using
mapplyorMap:For the most part, you shouldn’t be using
deparseandsubstituteunless you are doing metaprogramming (if you don’t know what it is, you’re not doing it).