Description Usage Arguments Details Note References Examples
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.
1 2 3 |
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 |
Please see describe
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.
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
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.