[R] Calculating means in a new table
Petr PIKAL
petr.pikal at precheza.cz
Tue Apr 24 14:20:40 CEST 2007
Hi
look at aggregate
something like
mymean<-aggregate(mydata[,4:5], list( location, Spezies....), mean)
mysd<-aggregate(mydata[,4:5], list( location, Spezies....), sd)
and then cbind(appropriate columns of resulting data frames)
Petr Pikal
petr.pikal at precheza.cz
r-help-bounces at stat.math.ethz.ch napsal dne 24.04.2007 14:04:30:
> Dear all -
> I imported (on a Mac) a big table with >2000 lines:
> > mydata <- read.table(file("/Users/didiw/Desktop/R/all.txt"), header =
TRUE)
> > mydata[1:15,]
> location Spezies Spec E.MPa. Phi No Trial
> 1 LC P J 13.27 7.51 1 1
> 2 LC P J 14.24 6.68 1 1
> 3 LC P J 14.28 7.01 2 1
> 4 LC P J 16.65 6.30 1 2
> ....
>
> Now i want to crate a new table "mymeans" where all means and Stdev
> of E.MPa and Phi when location, Spezies, No, and Trial are the same,
> something like this:
>
> location Spezies Spec No Trial mean.E stddev.E mean.Phi std.Phi
> 1 LC P J 1 1 xx xx xx xx
> 2 LC P J 2 1 xx xx xx xx
> 3 LC P J 1 2 xx xx xx xx
> ....
>
> Because I we did ca 8 repetition of each measurement, the new table
should
> have only 2000/8 lines.
>
> Thanks for any help!
>
> -didi
>
> ______________________________________________
> 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