[R] restructuring matrix

Moshe Olshansky m_olshansky at yahoo.com
Thu Jun 28 03:02:53 CEST 2007


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.

--- yoooooo <magno_yu at ml.com> wrote:

> 
> Hi all, 
> 
>     let's say I have matrix
> 
> People    Desc    Value
> Mary      Height    50
> Mary      Weight   100
> Fanny    Height     60
> Fanny     Height    200
> 
> Is there a quick way to form the following matrix? 
> 
> People   Height    Weight
> Mary      50         100
> Fanny     60        200
> 
> (Assuming I don't know the length of people/desc and
> let's say these are
> characters matrix.. I tried play with row(), col(),
> etc.. but I don't seem
> to find like a duplicate match function... 
> I'm trying to write some one/two liner that convert
> my resulting matrix to
> vector and pick the appropriate fields.. etc )
> 
> Thanks!
> 
> -- 
> View this message in context:
>
http://www.nabble.com/restructuring-matrix-tf3991741.html#a11334950
> Sent from the R help mailing list archive at
> Nabble.com.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>



More information about the R-help mailing list