My question is how to extract the name of a variable from a function that is called in another function in R?
To illustrate, here is an example:
a <- function(variable) {
print(deparse(substitute(variable)))
internala(substitute(variable))
}
internala <- function(variableXX) {
namex=deparse(substitute(variableXX))
print(namex)
}
Calling the function a
gives the following result:
>a(whatever)
[1] "whatever"
[1] "substitute(variable)"
which means that i can extract the name of the variable whatever
from a
, but not from internala
.
Any thoughts on this?
Any help will be appreciated!
Maria