[R] summary statistics

Henrique Dallazuanna wwwhsd at gmail.com
Tue Feb 12 19:33:19 CET 2008


Mode <- function(var)rownames(table(var))[which.max(table(var))]

as.data.frame(sapply(c("mean", "median", "Mode"),
function(fun)tapply(x$mgl, x$RM, fun, na.rm=T)))

On 12/02/2008, stephen sefick <ssefick at gmail.com> wrote:
> below is my data frame.  I would like to compute summary statistics
> for mgl for each river mile (mean, median, mode).  My apologies in
> advance-  I would like to get something like the SAS print out of PROC
> Univariate.  I have performed an ANOVA and a tukey LSD and I would
> just like the summary statistics.
> thanks
>
> stephen
>
> RM       mgl
> 1  215 0.9285714
> 2  215 0.7352941
> 3  215 1.6455696
> 4  215 0.6000000
> 5   sc 1.8333333
> 6   sc 0.8333333
> 7   sc 2.5438596
> 8   sc 0.2500000
> 9  202        NA
> 10 202 0.5500000
> 11 202 0.8148148
> 12 202 1.6666667
> 13 198 0.5038760
> 14 198 0.3823529
> 15 198 0.7600000
> 16 198 0.4800000
> 17  hc 3.1818182
> 18  hc 3.7254902
> 19  hc 4.3750000
> 20  hc 2.6415094
> 21 190 0.3500000
> 22 190 0.4400000
> 23 190 0.6500000
> 24 190 0.5000000
> 25  bc 9.0000000
> 26  bc 5.0000000
> 27  bc 4.0000000
> 28  bc 3.2000000
> 29 185 0.7386364
> 30 185 0.5000000
> 31 185 1.1538462
> 32 185 0.6000000
> 33 179 1.8181818
> 34 179 1.1980000
> 35 179 2.5000000
> 36 179 2.0000000
> 37 148 2.0833333
> 38 148 2.3333333
> 39 148 3.1000000
> 40 148 2.2142857
> 41 119 2.4444444
> 42 119 2.3275862
> 43 119 4.7142857
> 44 119 1.7692308
> 45  61 2.8888889
> 46  61 3.2500000
> 47  61 4.7500000
> 48  61 2.6337449
>
>
> --
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>                                                                 -K. Mullis
>
> ______________________________________________
> 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.
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list