describe.by {psych} | R Documentation |
Report basic summary statistics by a grouping variable. Useful if the grouping variable is some experimental variable and data are to be aggregated for plotting. Just a wrapper for by and describe
.
describe.by(x, group,...)
x |
a data.frame or matrix |
group |
a grouping variable |
... |
parameters to be passed to describe |
A data.frame of the relevant statistics broken down by group:
item name
item number
number of valid cases
mean
standard deviation
median
mad: median absolute deviation (from the median)
minimum
maximum
skew
standard error
William Revelle
set.seed(42) #to get the same values each time x.df <- data.frame(group=sample(2,20,replace=TRUE), matrix(rnorm(100),ncol=5)) x <- describe.by(x.df,x.df$group) x #shows all the results x[1] #shows just the first group x <- matrix(sample(4,200,replace=TRUE),ncol=5) y <- describe.by(x,x[,1]) y