Re: [R] 2 simple doubts

About this list Date view Thread view Subject view Author view Attachment view

From: Adaikalavan Ramasamy (ramasamy@stats.ox.ac.uk)
Date: Wed 10 Jul 2002 - 20:23:13 EST


Message-id: <00fb01c227fb$ccb1bcb0$a91401a3@stats.ox.ac.uk>


> 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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jun 2004 - 09:30:58 EST