Hi there fellow R-users, I'm stuck on this seemingly trivial problem. All I want to coerce a character string into a command. For example: x<-rnorm(20) y<-rnorm(20) str<-"lm(y~x)" I want to evaluate the "str" command. I have tried eval(as.expression(str)) But it doesn't seem to work. I am aware of the call command, but for reasons I won't go into I would prefer not to use it. Any help would be great. Regards, Wayne KSS Ltd Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England Company Registration Number 2800886 Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 mailto:kssg@kssg.com http://www.kssg.com The information in this Internet email is confidential and m...{{dropped}}
eval(parse(text = str)) -roger Wayne Jones wrote:> Hi there fellow R-users, > > I'm stuck on this seemingly trivial problem. > > All I want to coerce a character string into a command. > > For example: > > x<-rnorm(20) > y<-rnorm(20) > str<-"lm(y~x)" > > I want to evaluate the "str" command. > > I have tried > > eval(as.expression(str)) > > But it doesn't seem to work. I am aware of the call command, but for > reasons I won't go into I would prefer not to use it. > > Any help would be great. > > Regards, > Wayne > > > > > > KSS Ltd > Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England > Company Registration Number 2800886 > Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 > mailto:kssg at kssg.com http://www.kssg.com > > > The information in this Internet email is confidential and m...{{dropped}} > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
Hi Wayne, what you need is, eval(parse(text=str)) I hope this helps. Best, Dimitris ---- Dimitris Rizopoulos Doctoral Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/396887 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Wayne Jones" <JonesW at kssg.com> To: "R-help" <r-help at stat.math.ethz.ch> Sent: Monday, July 19, 2004 4:37 PM Subject: [R] converting character strings to eval> > Hi there fellow R-users, > > I'm stuck on this seemingly trivial problem. > > All I want to coerce a character string into a command. > > For example: > > x<-rnorm(20) > y<-rnorm(20) > str<-"lm(y~x)" > > I want to evaluate the "str" command. > > I have tried > > eval(as.expression(str)) > > But it doesn't seem to work. I am aware of the call command, butfor> reasons I won't go into I would prefer not to use it. > > Any help would be great. > > Regards, > Wayne > > > > > > KSS Ltd > Seventh Floor St James's Buildings 79 Oxford Street ManchesterM1 6SS England> Company Registration Number 2800886 > Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 > mailto:kssg at kssg.com http://www.kssg.com > > > The information in this Internet email is confidential andm...{{dropped}}> > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html
On Monday 19 July 2004 09:37, Wayne Jones wrote:> Hi there fellow R-users, > > I'm stuck on this seemingly trivial problem. > > All I want to coerce a character string into a command. > > For example: > > x<-rnorm(20) > y<-rnorm(20) > str<-"lm(y~x)" > > I want to evaluate the "str" command. > > I have tried > > eval(as.expression(str))eval(parse(text = str)) seems to work. Deepayan
Thanks folks, That's exactly what I needed. Thanks for the speedy replies. Regards Wayne -----Original Message----- From: Dimitris Rizopoulos [mailto:dimitris.rizopoulos@med.kuleuven.ac.be] Sent: 19 July 2004 15:49 To: Wayne Jones Cc: r-help@stat.math.ethz.ch Subject: Re: [R] converting character strings to eval Hi Wayne, what you need is, eval(parse(text=str)) I hope this helps. Best, Dimitris ---- Dimitris Rizopoulos Doctoral Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/396887 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Wayne Jones" <JonesW@kssg.com> To: "R-help" <r-help@stat.math.ethz.ch> Sent: Monday, July 19, 2004 4:37 PM Subject: [R] converting character strings to eval> > Hi there fellow R-users, > > I'm stuck on this seemingly trivial problem. > > All I want to coerce a character string into a command. > > For example: > > x<-rnorm(20) > y<-rnorm(20) > str<-"lm(y~x)" > > I want to evaluate the "str" command. > > I have tried > > eval(as.expression(str)) > > But it doesn't seem to work. I am aware of the call command, butfor> reasons I won't go into I would prefer not to use it. > > Any help would be great. > > Regards, > Wayne > > > > > > KSS Ltd > Seventh Floor St James's Buildings 79 Oxford Street ManchesterM1 6SS England> Company Registration Number 2800886 > Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 > mailto:kssg@kssg.com http://www.kssg.com > > > The information in this Internet email is confidential andm...{{dropped}}> > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]]
Hi, try with the package cluster! Bye Vito Hello, I'm trying to do a cluster analysis on a large data set. I tried it out with a smaller one first, but I got this error:> hc<-hclust(dist(x),"ave")Error: cannot allocate vector of size 4129151 Kb The data sample used (i.e. "x") is a numerical data set of size 32513 by 31 Does anyone know how I can do this analysis? Is R capable of this data size? Ultimately I wanna do an analysis on a dataset of size 32513 by 220 Thanks! dave ====Diventare costruttori di soluzioni Visitate il portale http://www.modugno.it/ e in particolare la sezione su Palese http://www.modugno.it/archivio/cat_palese.shtml