[R] Assessing the name of an object within an argument

G.Maubach at weinwolf.de G.Maubach at weinwolf.de
Tue Jan 10 09:49:19 CET 2017


Hi All,

I have a function like

my_func <- function(dataset)
{
  some operation
}

Now I would like not only to operate on the dataset (how this is done is 
obvious) but I would like to get the name of the dataset handed over as an 
argument.

Example:

my_func <- function(dataset = iris)
{
  print(dataset)  # here I do not want to print the dataset but the name 
of the object - iris in this case - instead
  # quote() does not do the trick cause it prints "dataset" instead of 
"iris"
  # as.name() gives an error saying that the object can not coerced to a 
symbol
}

Is there a way to do this?

Kind regards

Georg



More information about the R-help mailing list