Re: [R] Eval() or parse() do not work inside function

2010-07-27 Thread Greg Snow
; From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Jorge A. Ahumada > Sent: Tuesday, July 27, 2010 12:35 PM > To: r-help@r-project.org > Subject: [R] Eval() or parse() do not work inside function > > I am writing a function where the argume

Re: [R] Eval() or parse() do not work inside function

2010-07-27 Thread Jorge A. Ahumada
Yes, this solved the problem. Thanks. Jorge On 7/27/10 3:13 PM, "Duncan Murdoch" wrote: > On 27/07/2010 2:34 PM, Jorge A. Ahumada wrote: >> > I am writing a function where the arguments are names of objects or >> variable >> > names in a data frame. To convert the strings to the objects I am u

Re: [R] Eval() or parse() do not work inside function

2010-07-27 Thread Duncan Murdoch
On 27/07/2010 2:34 PM, Jorge A. Ahumada wrote: I am writing a function where the arguments are names of objects or variable names in a data frame. To convert the strings to the objects I am using eval(parse(text=name)): f.graph.two.vbs<-function(dataname,v1){ val<-paste(dataname,v1,sep

Re: [R] Eval() or parse() do not work inside function

2010-07-27 Thread Jorge A. Ahumada
Well, the data set I am using is quite large, but RECORD is also a numeric variable and data is a data frame. Here is my sessionInfo(): >sessionInfo() R version 2.11.0 (2010-04-22) i386-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1]

Re: [R] Eval() or parse() do not work inside function

2010-07-27 Thread Jorge Ivan Velez
Hi Jose, What's the problem? # some data set.seed(123) mydata <- data.frame(x = rnorm(10), y = rpois(10, 10)) mydata f.graph.two.vbs<-function(dataname,v1){ val<-paste(dataname,v1,sep="$") val<-eval(parse(text=val)) val } f.graph.two.vbs('mydata', 'x') [1] -0.56047565 -0.23

Re: [R] Eval() or parse() do not work inside function

2010-07-27 Thread Joshua Wiley
Dear Jorge, It might help if you included some sample data that replicates your problem, or, perhaps, the results of sessionInfo(). I cannot replicate it. Here are my results: > data <- data.frame(A = 1:10, RECORD = 1:10) > > f.graph.two.vbs<-function(dataname,v1){ + val<-paste(dataname,v1,s

[R] Eval() or parse() do not work inside function

2010-07-27 Thread Jorge A. Ahumada
I am writing a function where the arguments are names of objects or variable names in a data frame. To convert the strings to the objects I am using eval(parse(text=name)): f.graph.two.vbs<-function(dataname,v1){ val<-paste(dataname,v1,sep="$") val<-eval(parse(text=val)) val