[R] Re : Re : descriptive statistics

William Revelle lists at revelle.net
Mon Dec 13 17:56:39 CET 2010


An alternative way of getting summary statistics by a grouping 
variable is to use describe.by in the psych package:

using Jim Lemon's example:

library(psych)
testmat<-data.frame(sample(1:14,50,TRUE),rnorm(50),runif(50))  #make 
up the data
describe.by(test.mat,testmat[1]    #get descriptive statistics






At 8:17 AM -0800 12/13/10, effeesse wrote:
>what am I supposed to put into function(x)? The indicator for extracting the
>subgroups?
>data is the df. cluster={1,...,14}.
>
>This is how I was compiling:
>
>"for (i in 1:14) {
>my.summary<-data$cluster==i c(mean(?),var(?))
>
>summary(var_A~cluster, fun=my.summary,data=data)
>summary(var_B~cluster, fun=my.summary,data=data)
>summary(var_C~cluster, fun=my.summary,data=data)
>summary(var_D~cluster, fun=my.summary,data=data)
>summary(var_E~cluster, fun=my.summary,data=data)
>summary(var_F~cluster, fun=my.summary,data=data)
>summary(var_G~cluster, fun=my.summary,data=data)
>}"
>
>thanks for your patience.
>--
>View this message in context: 
>http://r.789695.n4.nabble.com/descriptive-statistics-tp3085197p3085651.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>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