[R] summary statistics into table/data base, many factors to analyse
Gabor Grothendieck
ggrothendieck at gmail.com
Thu Nov 20 15:32:34 CET 2008
Look at summaryBy in the doBy package.
On Thu, Nov 20, 2008 at 9:16 AM, Gerit Offermann <gerit.offermann at gmx.de> wrote:
> Dear list,
>
> I reduced my data to the following:
>
> x <- c(1,4,2,6,8,3,4,2,4,5,1,3)
> y <- as.factor(c(2,2,1,1,1,2,2,1,1,2,1,2))
> z <- as.factor(c(1,2,2,1,1,2,2,3,3,3,3,3))
>
> I can produce the statistical summary just fine.
> s1 <- tapply(x, y, summary)
> d1 <- tapply(x, y, sd)
> s2 <- tapply(x, z, summary)
> d2 <- tapply(x, z, sd)
>
> First thing:
> I have 100 plus factors to analyse. Theirs names are f1001 to f1381 (about).
> Is there a way to avoid having to write these lines 100 plus times?
>
> Second thing:
> How can I put the standard deviation and the summary statistics into one output?
>
> Third thing:
> In the end I want to write the summary statistics into a data base (Access). It would be fantastic if I could achieve a table such as:
>
> factor level Min. 1st Qu. Median Mean 3rd Qu. Max. SDev.
> y 1 1.000 2.000 3.000 3.833 5.500 8.000 2.714160
> y 2 1.000 3.000 3.500 3.333 4.000 5.000 1.366260
> z 1 1.0 3.5 6.0 5.0 7.0 8.0 3.6055513
> .
> .
> .
>
> I tried to unlist the matrices, but it did not help much.
> it <- NULL # "it" - Iterationen
>
> for (i in 1:nlevels(z)){
> it[[i]] <- unlist(s1[[i]])}
>
>
> Help to any of the three points is greatly appreciated.
>
> Cheers,
> Gerit
> --
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list