[R] restructuring matrix

2007-06-27 Thread yoooooo
Hi all, let's say I have matrix PeopleDescValue Mary Height50 Mary Weight 100 FannyHeight 60 Fanny Height200 Is there a quick way to form the following matrix? People HeightWeight Mary 50 100 Fanny 60200 (Assuming I

Re: [R] restructuring matrix

2007-06-27 Thread Moshe Olshansky
If your original matrix is A then unique(A$People) and unique(A$Desc) will produce a vector of different people and a vector of different descriptions. --- yoo [EMAIL PROTECTED] wrote: Hi all, let's say I have matrix PeopleDescValue Mary Height50 Mary

Re: [R] restructuring matrix

2007-06-27 Thread yoooooo
Yea... let's say I constructed a matrix with rownames/colnames be those unique elements.. then what should I do? I don't want to do mapply, etc to find the field.. I'm wondering if there's a smarter way using row/col.. etc... Thanks! Moshe Olshansky-2 wrote: If your original matrix is A

Re: [R] restructuring matrix

2007-06-27 Thread jim holtman
Is this what you want? x - PeopleDescValue + Mary Height50 + Mary Weight 100 + FannyHeight 60 + Fanny Weight200 x - read.table(textConnection(x), header=TRUE, as.is=TRUE) reshape(x, direction='wide', idvar=People, timevar=Desc) People Value.Height