One possibility is
aggregate(iris[,-5],list(iris[,5]),mean)
Group.1 Sepal.Length Sepal.Width Petal.Length Petal.Width
1 setosa5.006 3.4281.462 0.246
2 versicolor5.936 2.7704.260 1.326
3 virginica6.588 2.9745
: Re: [R] question about "mean"
apply(iris[, -5], 2, tapply, iris$Species, mean)
On Wed, Jun 9, 2010 at 3:43 PM, SH.Chou wrote:
> Hi there:
> I have a question about generating mean value of a data.frame. Take
> iris data for example, if I have a data.frame looking
apply(iris[, -5], 2, tapply, iris$Species, mean)
On Wed, Jun 9, 2010 at 3:43 PM, SH.Chou wrote:
> Hi there:
> I have a question about generating mean value of a data.frame. Take
> iris data for example, if I have a data.frame looking like the following:
> -
>Sepal.Len
Hi there:
I have a question about generating mean value of a data.frame. Take
iris data for example, if I have a data.frame looking like the following:
-
Sepal.Length Sepal.Width Petal.Length Petal.WidthSpecies
15.1 3.5
Rolf Turner wrote:
>
> On 9/02/2009, at 4:40 PM, bill.venab...@csiro.au wrote:
>
>> Store your 'matrix' as a data frame.
>
> Surely it's a data frame already, since ``school'' is character or
> factor,
> and ``value'' is (must be?) numeric.
>
> People have this unfortunate predilection
On 9/02/2009, at 4:40 PM, bill.venab...@csiro.au wrote:
Store your 'matrix' as a data frame.
Surely it's a data frame already, since ``school'' is character or
factor,
and ``value'' is (must be?) numeric.
People have this unfortunate predilection to refer to data frames a
E))
Bill Venables
http://www.cmis.csiro.au/bill.venables/
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of cindy Guo
Sent: Monday, 9 February 2009 1:32 PM
To: r-help@r-project.org
Subject: [R] question about mean
Hello, every
Hello, everyone,
I have a matrix like following:
school value
A .1
A .2
A .15
A .2
B .3
B .5
C .3
C .3
C .4
C .5
C .6
C .9
C 1
I want to get the mean 'value' for each 'school', b
8 matches
Mail list logo