; 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
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
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
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]
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
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
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
7 matches
Mail list logo