psych (version 1.8.12)

describeBy: Basic summary statistics by group


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. Partly a wrapper for by and describe


describeBy(x, group=NULL,mat=FALSE,type=3,digits=15,...), group=NULL,mat=FALSE,type=3,...)  # deprecated



a data.frame or matrix. See note for statsBy.


a grouping variable or a list of grouping variables


provide a matrix output rather than a list


Which type of skew and kurtosis should be found


When giving matrix output, how many digits should be reported?


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


To get descriptive statistics for several different grouping variables, make sure that group is a list. In the case of matrix output with multiple grouping variables, the grouping variable values are added to the output.

The type parameter specifies which version of skew and kurtosis should be found. See describe for more details.

An alternative function (statsBy) returns a list of means, n, and standard deviations for each group. This is particularly useful if finding weighted correlations of group means using cor.wt. More importantly, it does a proper within and between group decomposition of the correlation.

cohen.d will work for two groups. It converts the data into mean differences and pools the within group standard deviations. Returns cohen.d statistic as well as the multivariate generalization (Mahalanobis D).

See Also

describe, statsBy, densityBy and violinBy, cohen.d,, and as well as error.bars and for other graphical displays.


describeBy(sat.act,sat.act$gender) #just one grouping variable	
#describeBy(sat.act,list(sat.act$gender,sat.act$education))  #two grouping variables
des.mat <- describeBy(sat.act$age,sat.act$education,mat=TRUE) #matrix (data.frame) output 
des.mat <- describeBy(sat.act$age,list(sat.act$education,sat.act$gender),
             mat=TRUE,digits=2)  #matrix output

# }