Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] how to generate argument from a vector automatically

zhihua li

2005-07-12

Replies:

hi netters

i have a vector NAMES containing a series of variable names:
NAMES=c(x,r,z,m,st,qr,.....nn).
i wanna fit a regression tree by using the code:
      my.tree<-tree(y~x+r+z+m+....nn,my.dataframe)

but i don't want to type out "x+r+z+m+....+nn" one by one, as there are so
many variables. besides, sometimes i wanna put the code in a function. so i
need to have the argument "x+r+z+m+....+nn" generated from NAMES
automatically.

i've tried the code: paste(X,collpase="+") but it didn't work.

could anybody give me a hint?

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.