[R] transforming a matrix

David Winsemius dwinsemius at comcast.net
Fri Mar 13 22:18:24 CET 2009


Am I correct in thinking that you actually want a function that will  
take the three row matrix

Ystart <- matrix(c(1:3, 34,-56,27), ncol=2) and return the 4 column  
matrix offered?

As it is I see no way that we could know what rule you wanted to apply  
to that four row X matrix to get the 9 row Y matrix. I suppose this  
could be one of those intelligence test questions that I won't get  
right and thereby fail my entrance exams.

-- 
David Winsemius
On Mar 13, 2009, at 3:56 PM, Dimitri Szerman wrote:

> Hello,
> I have a matrix such as
>
>> X = matrix(c(1:4,29,32,56,-45), ncol=2)
>
> and I want one like
>
>> Y=matrix(c(
> 1 , 34 , 1 , 34 ,
> 2 , -56 , 1 , 34 ,
> 3 , 27 , 1 , 34 ,
> 1 , 34 , 2 , -56 ,
> 2 , -56 , 2 , -56 ,
> 3 , 27 , 2 , -56 ,
> 1 , 34 , 3 , 27 ,
> 2 , -56 , 3 , 27 ,
> 3 , 27 , 3 , 27 ), ncol=4, byrow=T)
>
> How do I do this in an efficient and elegant way?
>
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list