Re: [R] How to manipulate data according to groups ?

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Thu, 13 Mar 2008 15:48:41 -0400 (EDT)


?aggregate

 tt <- matrix(c(rnorm(10), 1,1,2,2,1,3,3,3,3,2), ncol=2))
 aggregate(t[,1], by=list(t[,2]), mean)
should work

> Hi,
>
> I have a two columns data, the first column are
> values, and second column
> are the groups. For this example, there are 3 groups
> 1,2,3.
>
> How can I manipulate the values in the first column
> according to groups, say
> I would like to find mean, sum, and standard
> deviation for the different
> groups ? How do I plot data according to groups ?
>
> > t <- matrix(c(rnorm(10), 1,1,2,2,1,3,3,3,3,2),
> ncol=2)
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org 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.
>



R-help_at_r-project.org 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 13 Mar 2008 - 19:51:00 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 13 Mar 2008 - 21:30:21 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.

list of date sections of archive