Check the package doBy as well (pretty handy for analysis of grouped data).
library(doBy)
summaryBy(PM~ID,data=d,FUN=median)
HTH,
-Girish
--
View this message in context:
http://n4.nabble.com/median-of-grouped-data-tp1311971p1312386.html
Sent from the R help mailing list archive at Nabble.com.
ery Biologist Department of the Interior US Fish & Wildlife
Service California, USA
--- On Wed, 1/27/10, "María del Pilar Márquez" wrote:
> From: "María del Pilar Márquez"
> Subject: [R] median of grouped data
> To: r-help@r-project.org
> Date: Wednesda
day, 28 January 2010 7:06 a.m.
> To: r-help@r-project.org
> Subject: [R] median of grouped data
>
> Good morning,
> I would like to know if is possible somebody can help me with
> this please:
> I would like to calculate the median of grouped data, this is
> an example
Good morning,
I would like to know if is possible somebody can help me with this please:
I would like to calculate the median of grouped data, this is an example:
IDPM
adt_01 25.255
adt_01 225.36
adt_01 14.2325
adt_02 15
adt_02 12.3
adt_03 15.2
adt_03 148.3
adt_03 25.5
adt_03 14.25
I
On 28 июн, 03:19, "Bricklemyer, Ross S" <[EMAIL PROTECTED]> wrote:
> I am having difficulty calculating the median of grouped data. I have 8 to
> 10 repeated measures per sample and I have successfully used the following
> code to calculate the average for each sample.
>
> libs.norm.preds.median
jim holtman wrote:
Is this what you want:
# split the dataframe by the grouping (z was your sample data)
z.s <- split(z, z[[1]])
# calculate the median
(ans <- lapply(z.s, function(.grp) apply(.grp[,7:9], 2, median)))
$HOR006_3
TC.15_comps IC.16_comps SOC.17_comps
10.549669 4.
Is this what you want:
> # split the dataframe by the grouping (z was your sample data)
> z.s <- split(z, z[[1]])
> # calculate the median
> (ans <- lapply(z.s, function(.grp) apply(.grp[,7:9], 2, median)))
$HOR006_3
TC.15_comps IC.16_comps SOC.17_comps
10.549669 4.224790 7.012470
$H
I am having difficulty calculating the median of grouped data. I have 8 to 10
repeated measures per sample and I have successfully used the following code to
calculate the average for each sample.
libs.norm.preds.median[,7:9]<-apply(libs.norm.preds.median[,7:9],MARGIN=2,
FUN=ave,libs.norm.pred
8 matches
Mail list logo