Boris Mayer
2011-Nov-22 20:26 UTC
[R] Rcmdr numSummary: means of multiple variables without grouping
Hello there, when using the function numSummary in Rcmdr and selecting more than one variable (without grouping), the grand mean across all variables is returned for each variable instead of the mean of each single variable. However, this happens only for the mean, and not for sd, quantiles and na. This is the output:> numSummary(dataset1 [,c("var1", "var2")],+ statistics=c("mean", "sd", "quantiles"), quantiles=c(0,.25,.5,.75,1)) mean sd 0% 25% 50% 75% 100% n NA var1 15.58491 4.154637 10 14 15 19.5 28 54 0 var2 15.58491 5.904053 5 10 15 18.5 30 52 2 When using a grouping variable, everything is fine:> numSummary(dataset1 [,c("var1", "var2")],+ groups= dataset1$gender, statistics=c("mean", "sd", "quantiles"), + quantiles=c(0,.25,.5,.75,1)) Variable: var1 mean sd 0% 25% 50% 75% 100% n NA male 16.57895 4.634602 10 14 16 20 28 19 0 female 16.28571 3.937538 10 14 15 18 28 35 0 Variable: var2 mean sd 0% 25% 50% 75% 100% n NA male 14.72222 5.442810 8 10 14 15.0 28 18 1 female 14.76471 6.213664 5 10 15 19.5 30 34 1 Any ideas how to get separate means for multiple variables in numSummary without grouping? I am using R 2.14.0 and Rcmdr 1.7.2 on Windows 7 Professional. Thanks in advance! Boris [[alternative HTML version deleted]]
John Fox
2011-Nov-22 23:16 UTC
[R] Rcmdr numSummary: means of multiple variables without grouping
Dear Boris, This bug is traceable to a change in the mean() function in R and is fixed in the current version (1.7-3) of the Rcmdr package on CRAN. Best, John ------------------------------------------------ John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Tue, 22 Nov 2011 21:26:41 +0100 "Boris Mayer" <bocaboa3 at googlemail.com> wrote:> Hello there, > > > > when using the function numSummary in Rcmdr and selecting more than one > variable (without grouping), the grand mean across all variables is returned > for each variable instead of the mean of each single variable. However, this > happens only for the mean, and not for sd, quantiles and na. > > > > This is the output: > > > > > numSummary(dataset1 [,c("var1", "var2")], > > + statistics=c("mean", "sd", "quantiles"), quantiles=c(0,.25,.5,.75,1)) > > mean sd 0% 25% 50% 75% 100% n NA > > var1 15.58491 4.154637 10 14 15 19.5 28 54 0 > > var2 15.58491 5.904053 5 10 15 18.5 30 52 2 > > > > > > When using a grouping variable, everything is fine: > > > > > > > numSummary(dataset1 [,c("var1", "var2")], > > + groups= dataset1$gender, statistics=c("mean", "sd", "quantiles"), > > + quantiles=c(0,.25,.5,.75,1)) > > > > Variable: var1 > > mean sd 0% 25% 50% 75% 100% n NA > > male 16.57895 4.634602 10 14 16 20 28 19 0 > > female 16.28571 3.937538 10 14 15 18 28 35 0 > > > > Variable: var2 > > mean sd 0% 25% 50% 75% 100% n NA > > male 14.72222 5.442810 8 10 14 15.0 28 18 1 > > female 14.76471 6.213664 5 10 15 19.5 30 34 1 > > > > > > > > Any ideas how to get separate means for multiple variables in numSummary > without grouping? > > > > I am using R 2.14.0 and Rcmdr 1.7.2 on Windows 7 Professional. > > > > Thanks in advance! > > > > Boris > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.