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

Hadley Wickham h.wickham at gmail.com
Tue Jan 10 16:58:44 CET 2017


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,  <G.Maubach at weinwolf.de> wrote:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
http://hadley.nz



More information about the R-help mailing list