Descriptive stats with the psych package

There a several options for the expedient production of descriptive statistics in R. The one you will commonly end up using will be the one that produces the most useful stats for you. My personal favourite is the descriptives produced by the psych package. I find that the descriptives are most useful for me in my work, the introduction of skew and kurtosis is useful for understanding the shape of your data before having plotted it. Descriptives are produced using the describe() function. The only required argument is a vector of data whether from a data frame or an array.


Input:
library(psych)
data <- data.frame(ID=seq(1,25,1), Age=sample(18:99,25,replace=TRUE), Gender=sample(1:2,25,replace=TRUE),
                   Score=sample(0:50,25,replace=TRUE))
ageSum <- describe(data$Age)
ageSum

Output:
vars n mean sd median trimmed mad min max range skew kurtosis se
X1 1 25 60.8 20.04994 59 61.33333 20.7564 21 94 73 -0.04966703 -0.8373389 4.009988

The psych package also has an easy to use describe by group function. In the example below we use the describeBy() function to produce descriptives for the variable age by gender.


Input:
ageGenSum <- describeBy(data$Age,data$Gender)
ageGenSum

Output:
 Descriptive statistics by group 
group: 1
   vars  n  mean    sd median trimmed   mad min max range  skew kurtosis   se
X1    1 14 64.64 18.79   59.5   66.08 11.12  21  91    70 -0.43    -0.24 5.02
------------------------------------------------------------ 
group: 2
   vars  n  mean    sd median trimmed   mad min max range skew kurtosis   se
X1    1 11 55.91 21.42     51      55 16.31  26  94    68 0.42    -1.12 6.46

The psych package also contains many useful functions particularly for factor analysis and structural equation modelling.