Re: [R] restructuring matrix

From: jim holtman <jholtman_at_gmail.com>
Date: Wed, 27 Jun 2007 21:56:06 -0400

Is this what you want?

> x <- "People Desc Value

+ Mary      Height    50
+ Mary      Weight   100
+ Fanny    Height     60
+ Fanny     Weight    200"

> x <- read.table(textConnection(x), header=TRUE, as.is=TRUE)
> reshape(x, direction='wide', idvar="People", timevar="Desc")
  People Value.Height Value.Weight
1   Mary           50          100
3  Fanny           60          200

>
>

On 6/27/07, 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.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]

______________________________________________
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.
Received on Thu 28 Jun 2007 - 02:10:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 28 Jun 2007 - 03:32:40 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.