Hello, I'm just start learning R/S-Plus, so I think this 2 doubts is going to be too easy for you... 1) I couldn't discover what is the command for a concatenation of 2 variable strings. 2) For example, if I have three variable strings, and each one has the name of a variable in a data matrix: a<-V1 b<-V2 c<-V3 , is it possible to construct a command like this: tree(a~b+c,data=DS1) , that would do the job of tree(V1~V2+V3,data=DS1) ? I know that how I've written here doesn't work, but I hope I've explained well what I'd like to do. Thanks. Sincerely, -- Frederico Zanqueta Poleto fred at poleto.com - ICQ# 4129787 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 1) I couldn't discover what is the command for a concatenation of 2 > variable strings.You can use c, cbind, rbind. Example follow : x <- c(1,2,46) which returns you a vector of length 3 containing the number 1,2, 4 if you have a numerical matrix of say X, Y, Z each of dim 10 by 2 then A <- cbind(X,Y,Z) binds the colums together to give a matrix of 10 by 6 or B <- rbind( X,Y,Z) binds the rows together to give a matrix of 30 by 2 If some of your vectors are non-numerical, then you may have to use the data.frame option instead.> 2) For example, if I have three variable strings, and each one has the > name of a variable in a data matrix: > a<-V1 > b<-V2 > c<-V3 > , is it possible to construct a command like this: > tree(a~b+c,data=DS1) > , that would do the job of tree(V1~V2+V3,data=DS1) ?Hmm, I am not quite sure what you are asking but you best try with a small manage matrix first. I think you are trying the change the names of your columns right ? If so try this colnames(DS1) <- c( "a", "b", "c") Note the quotes around a,b, c. Thus you need not to extract each vector by its own. Again for dataframes, the naming procedure is slightly different. refer to ?data.frame. Regards, Adai. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello Frederico 1) paste(strA,strB,....strX,sep='') or something else as seperator (default: blank ' ') 2) tree(as.formula(paste(a,'~',b,'+',c)),data=DS1) could work gruess joerg Frederico Zanqueta Poleto wrote:> > Hello, > > I'm just start learning R/S-Plus, so I think this 2 doubts is going to > be too easy for you... > > 1) I couldn't discover what is the command for a concatenation of 2 > variable strings. > > 2) For example, if I have three variable strings, and each one has the > name of a variable in a data matrix: > a<-V1 > b<-V2 > c<-V3 > , is it possible to construct a command like this: > tree(a~b+c,data=DS1) > , that would do the job of tree(V1~V2+V3,data=DS1) ? > I know that how I've written here doesn't work, but I hope I've > explained well what I'd like to do. > > Thanks. > > Sincerely, > -- > Frederico Zanqueta Poleto > fred at poleto.com - ICQ# 4129787 > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Joerg Maeder .:|:||:..:.||.:: maeder at atmos.umnw.ethz.ch Tel: +41 1 633 36 25 .:|:||:..:.||.:: http://www.iac.ethz.ch/staff/maeder PhD student at INSTITUTE FOR ATMOSPHERIC AND CLIMATE SCIENCE (IACETH) ETH Z?RICH Switzerland -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Frederico Zanqueta Poleto <fred at poleto.com> wrote:> 1) I couldn't discover what is the command for a concatenation of 2 > variable strings.Assuming you mean string concatenation, not vector concatenation... I find this little utility function extremely convenient: R> "%&%" <- function(a, b) paste(a, b, sep="") R> "x" %&% "yz" [1] "xyz" R> c("a","A") %&% c("b","B") %&% c("c","C") [1] "abc" "ABC" -- -- David Brahm (brahm at alum.mit.edu) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._