stat_describe: Basic descriptive statistics derived from psych package

Description Usage Arguments Details Note References Examples

Description

There are many summary statistics available in R; this function provides the ones most useful for scale construction and item analysis in classic psychometrics. Range is most useful for the first pass in a data set, to check for coding errors.

Usage

1
2
3
stat_describe(x, na.rm = TRUE, interp = FALSE, skew = TRUE,
  ranges = TRUE, trim = 0.1, type = 3, check = TRUE, fast = NULL,
  quant = NULL, IQR = FALSE)

Arguments

x

A data frame or matrix

na.rm

The default is to delete missing data. na.rm=FALSE will delete the case.

interp

Should the median be standard or interpolated

skew

Should the skew and kurtosis be calculated?

ranges

Should the range be calculated?

trim

trim=.1 – trim means by dropping the top and bottom trim fraction

type

Which estimate of skew and kurtosis should be used? (See details.)

check

Should we check for non-numeric variables? Slower but helpful.

quant

if not NULL, will find the specified quantiles. e.g quant=c(.25,.75) will find the 25th and 75th percentiles.

IQR

If TRUE, show the interquartile range

head

show the first 1:head cases for each variable in describeData

tail

Show the last nobs-tail cases for each variable in describeData

Details

Please see describe

Note

The object returned is a data frame with the normal precision of R. However, to control the number of digits displayed, you can set digits in a print command, rather than losing precision at the descriptive stats level. See the last two examples. One just sets the number of digits, one gives uses signif to make 'prettier' output where all numbers are displayed to the same number of digits.

References

Joanes, D.N. and Gill, C.A (1998). Comparing measures of sample skewness and kurtosis. The Statistician, 47, 183-189.

Revelle, W. (2017) psych: Procedures for Personality and Psychological Research, Northwestern University, Evanston, Illinois, USA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
   data(mtcars)
   stat_describe(mtcars)
   stat_describe(mtcars,skew=FALSE)
   stat_describe(mtcars,IQR=TRUE) #show the interquartile Range
   stat_describe(mtcars,quant=c(.1,.25,.5,.75,.90) ) #find the 10th, 25th, 50th,
   #75th and 90th percentiles
   stat_describeData(mtcars) #the fast version
   #now show how to adjust the displayed number of digits
   des <- stat_describe(mtcars)  #find the descriptive statistics.  Keep the original accuracy
   des  #show the normal output, which is rounded to 2 decimals
   print(des,digits=3)  #show the output, but round to 3 (trailing) digits
   print(des, signif=3) #round all numbers to the 3 significant digits

ShouyeLiu/metaboliteUtility documentation built on May 6, 2019, 9:07 a.m.