[R] Extracting the name of an object into a character string
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Thu Dec 11 13:34:25 CET 2008
do you mean something like the following:
f <- function (x) {
deparse(substitute(x))
}
x <- 5
y <- 6
z <- 7
f(x)
f(y)
f(z)
I hope it helps.
Best,
Dimitris
Philip Whittall wrote:
> Dear List,
>
> I am writing a function in R with the facility to store models for later
> use in scoring.
> It would be very useful if I could include in the name of the file
> stored the name of
> the model object being stored, this name being chosen by the user in the
> function
> call. A simple function to store the name of an object as a character
> string would fit the
> bill, but I have not found one. name() doesn't appear to do what I want,
> maybe I'm using
> it wrongly. Any suggestions please ? I'm running 2.8.0 on windows XP,
>
> Thanks,
>
> Philip
>
>
>
>
> This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately.
> Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory. The contents of this email may relate to dealings with other companies within the Detica Group plc group of companies.
>
> Detica Limited is registered in England under No: 1337451.
>
> Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, England.
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
More information about the R-help
mailing list