Re: [R] Extracting the name of an object into a character string and vice versa

2008-12-13 Thread David Winsemius
On Dec 12, 2008, at 8:41 AM, Gabor Grothendieck wrote: Its a FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f On Fri, Dec 12, 2008 at 8:30 AM, Philip Whittall wrote: I am still struggling to map a character string to an object name and vice ver

Re: [R] Extracting the name of an object into a character string and vice versa

2008-12-12 Thread Simon Pickett
paste() ?paste - Original Message - From: "Philip Whittall" To: Sent: Friday, December 12, 2008 1:30 PM Subject: Re: [R] Extracting the name of an object into a character string and vice versa I am still struggling to map a character string to an object name and vic

Re: [R] Extracting the name of an object into a character string and vice versa

2008-12-12 Thread Gabor Grothendieck
Its a FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f On Fri, Dec 12, 2008 at 8:30 AM, Philip Whittall wrote: > > I am still struggling to map a character string to an object name and > vice versa in R. > I thought the as.name() function might work,

Re: [R] Extracting the name of an object into a character string and vice versa

2008-12-12 Thread Philip Whittall
I am still struggling to map a character string to an object name and vice versa in R. I thought the as.name() function might work, but observe the following behaviour ... > attach(warpbreaks) > levels(tension) [1] "L" "M" "H" > levels(as.name("tension")) NULL > objectname<-as.name("tension") >

Re: [R] Extracting the name of an object into a character string

2008-12-11 Thread Dimitris Rizopoulos
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 wou

[R] Extracting the name of an object into a character string

2008-12-11 Thread Philip Whittall
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 sto