[R] learning R

David Winsemius dwinsemius at comcast.net
Wed Feb 25 06:17:33 CET 2009


On Feb 25, 2009, at 12:12 AM, David Winsemius wrote:

>
> On Feb 24, 2009, at 11:36 PM, Fuchs Ira wrote:
>
>>
>
>
>>
>> also unrelated:  if I have two vectors and I want to combine them  
>> to form a matrix ,is cbind (or rbind) the most direct way to do this?
>>
>> e.g.
>>
>> x=c(1,2,3)
>> y=c(3,4,5)
>> z=rbind(x,y)
>
> That is ok. Also effective would be:
>
> z <- matrix( c(x,y), ncol=length(x) )
>>

Would need byrow=TRUE for that to behave as desired.
 > z <- matrix(c(x,y), 2.3, byrow=TRUE)
 > z
      [,1] [,2] [,3]
[1,]    1    2    3
[2,]    3    4    5


-- 
David Winsemius




More information about the R-help mailing list