Thanks
Here is another question 

I want to have a function that get a string for example
y="AMI" and make commands like the following

agg<-aggregate(numAMI ~MemberID,right.a,sum)

Note that I know that numAMI is part of right.a because another function
with the string AMI already generated it.

Is there a way to do it without paste parse and eval?

I can do it by the following commands for y="AMI"

numy<-paste("num",y,sep="")
texta<-paste("agg<-aggregate(",numy,sep="")
text2<-"~MemberID, right.a, sum)"
text1<-paste(texta,text2,sep="")
eval(parse(text=text1))

If you can have a shorter code for it then it can be productive.

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-translate-string-to-variable-inside-a-command-in-an-easy-way-in-R-tp3645594p3665462.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to