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

2017-01-10 Thread Hadley Wickham
You might find http://adv-r.had.co.nz/Computing-on-the-language.html helpful. Hadley On Tue, Jan 10, 2017 at 2:49 AM, wrote: > Hi All, > > I have a function like > > my_func <- function(dataset) > { > some operation > } > > Now I would like not only to operate on the

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

2017-01-10 Thread Thomas Mailund
Yes, I was too fast there, sorry. I sent a correction right after but must have picked Reply instead of Replay All. Cheers Thomas On 10 January 2017 at 10:31:30, Bert Gunter (bgunter.4...@gmail.com) wrote: This is false. formals() gives the FORMAL argument

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

2017-01-10 Thread Bert Gunter
This is false. formals() gives the FORMAL argument list of the function, not the ACTUAL arguments supplied. That is obtained by the construction deparse(substitute(dataset)) The OP should consult a good R tutorial for this and other uses of substitute(), part of the "computing on the language"

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

2017-01-10 Thread Thomas Mailund
  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

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

2017-01-10 Thread G . Maubach
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) {