[R] Accesing the name of an assigned object in a function
Thomas Lumley
tlumley at u.washington.edu
Wed Sep 1 16:29:05 CEST 2004
On Wed, 1 Sep 2004, Eryk Wolski wrote:
> ?assign
No, this is not going to work.
If Henrik has described his wish correctly, he wants to execute the call
assigned.name <- stupid.function(whatever)
and be able, inside stupid.function, to find out what name the result is
going to be assigned to. This is, I think, impossible.
If assigned.name is passed as an argument of stupid.function then it is
possible, but assign() isn't necessary.
-thomas
>
> /E
>
> On Wed, 1 Sep 2004, Henrik Andersson wrote:
>
> > I want to use the name that I assign to an object in the function that
> > produces the output, somewhat like below:
> >
> > stupid.function <- function(input){
> > [body]
> > cat("Summarized output is ", output$summary, "Full output is given
> > by typing", assigned.name, "\n")
> > }
> >
> > assigned.name <- stupid.function(whatever)
> >
> >
> > or another example is a function that sinks the results to a text file
> > and names it assigned.name.txt .
> >
> > I checked the help for function, <-, assign but could not find it, is it
> > possible ?
> >
> >
> > ---------------------------------------------
> > Henrik Andersson
> > Netherlands Institute of Ecology -
> > Centre for Estuarine and Marine Ecology
> > P.O. Box 140
> > 4400 AC Yerseke
> > Phone: +31 113 577473
> > h.andersson at nioo.knaw.nl
> > http://www.nioo.knaw.nl/ppages/handersson
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> >
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help
mailing list