Skip to content
Prev 366533 / 398502 Next

Assessing the name of an object within an argument

?
You can get that using `formals()`.  

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

? print(formals()$dataset) # this is what you want
}

This gives you what the arguments were as an alist. It won?t always be a name, of course, but when it is, as in this case, that will be a symbol you can print.

Cheers
	Thomas
On 10 January 2017 at 09:51:55, g.maubach at weinwolf.de (g.maubach at weinwolf.de(mailto:g.maubach at weinwolf.de)) wrote: