Here is one way of doing it: (no exactly sure if 'mode' makes sense with your data)
> x <- read.table(textConnection("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"), header=TRUE) > # compute the stats > x.stats <- by(x, x$RM, function(.rm){ + c(mean=mean(.rm$mgl, na.rm=TRUE), median=median(.rm$mgl, na.rm=TRUE)) + }) > do.call(rbind, x.stats) mean median 119 2.8138868 2.3860153 148 2.4327381 2.2738095 179 1.8790455 1.9090909 185 0.7481206 0.6693182 190 0.4850000 0.4700000 198 0.5315572 0.4919380 202 1.0104938 0.8148148 215 0.9773588 0.8319327 61 3.3806584 3.0694444 bc 5.3000000 4.5000000 hc 3.4809545 3.4536542 sc 1.3651316 1.3333333 > > On Feb 12, 2008 11:57 AM, stephen sefick <[EMAIL PROTECTED]> 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@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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ R-help@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.