Today, we will use the describe function in R, which takes the form of describe (dataset). Any data type, including missing data, can be passed to the function. It generates a contingency table that provides details about the dataset. The data structure examines the actual content of the table.
What is describe function in R?
The most useful summary statistics for scale design and item analysis in traditional psychometrics are provided by this function out of the various summary statistics available in R. Range is particularly helpful when running through a data set once to look for coding problems.
The syntax of Describe in R
describe(data,na.rm=TRUE,type=3,interp=FALSE, skew=TRUE,ranges=TRUE, IQR=FALSE,omit=FALSE,data=NULL, check=TRUE,fast=NULL,quant=NULL)
Parameters:
- data: is a matrix, dataframe, vector, …
- na.rm: If na.rm==FALSE, remove the case. The default will delete missing values.
- interp: The median of a standard.
- ranges: The ranges.
- …
- data: Formula input for particular grouping variables is possible.
The example of this function
First, we will use the psych package for this function. You can click this link to learn how to install the package.
Or you can run the code below if you still need to get it automatically on-site download.
if(!require('psych')) { install.packages('psych') library('psych') }
We can use the describe function in R to describe the iris dataset, which is available in R.
# describe iris dataset des <- describe(airquality) des # print names print("The names in describe(airquality): ") names(des)
Output
vars n mean sd median trimmed mad
Ozone 1 116 42.1293 32.9879 31.5 37.7979 25.9455
Solar.R 2 146 185.9315 90.0584 205 190.339 98.5929
Wind 3 153 9.9575 3.523 9.7 9.8699 3.41
Temp 4 153 77.8824 9.4653 79 78.2846 8.8956
Month 5 153 6.9935 1.4165 7 6.9919 1.4826
Day 6 153 15.8039 8.8645 16 15.8049 11.8608
min max range skew kurtosis se
Ozone 1 168 167 1.2099 1.1122 3.0628
Solar.R 7 334 327 -0.4193 -1.0041 7.4533
Wind 1.7 20.7 19 0.341 0.0289 0.2848
Temp 56 97 41 -0.3705 -0.4629 0.7652
Month 5 9 4 -0.0023 -1.3167 0.1145
Day 1 31 30 0.0026 -1.2224 0.7167
[1] "The names in describe(airquality): "
'vars''n''mean''sd''median''trimmed''mad''min''max''range''skew''kurtosis''se'
We can round digits or significant digits as follows:
# Initial dataset des <- describe(airquality) names(describe(airquality)) print("Round to 2 digits: ") print(des,digits=2) print("Round the 2 significant digits" ) print(des, signif=2)
Output
'vars''n''mean''sd''median''trimmed''mad''min''max''range''skew''kurtosis''se'
[1] "Round to 2 digits: "
vars n mean sd median trimmed mad min max range skew
Ozone 1 116 42.13 32.99 31.5 37.80 25.95 1.0 168.0 167 1.21
Solar.R 2 146 185.93 90.06 205.0 190.34 98.59 7.0 334.0 327 -0.42
Wind 3 153 9.96 3.52 9.7 9.87 3.41 1.7 20.7 19 0.34
Temp 4 153 77.88 9.47 79.0 78.28 8.90 56.0 97.0 41 -0.37
Month 5 153 6.99 1.42 7.0 6.99 1.48 5.0 9.0 4 0.00
Day 6 153 15.80 8.86 16.0 15.80 11.86 1.0 31.0 30 0.00
kurtosis se
Ozone 1.11 3.06
Solar.R -1.00 7.45
Wind 0.03 0.28
Temp -0.46 0.77
Month -1.32 0.11
Day -1.22 0.72
[1] "Round the 2 significant digits"
vars n mean sd median trimmed mad min max range skew kurtosis se
Ozone 1 120 42 33.0 31.0 38.0 26.0 1.0 170 170 1.2 1.10 3.1
Solar.R 2 150 190 90.0 200.0 190.0 99.0 7.0 330 330 -0.4 -1.00 7.5
Wind 3 150 10 3.5 9.7 9.9 3.4 1.7 21 19 0.3 0.03 0.3
Temp 4 150 78 9.5 79.0 78.0 8.9 56.0 97 41 -0.4 -0.50 0.8
Month 5 150 7 1.4 7.0 7.0 1.5 5.0 9 4 0.0 -1.30 0.1
Day 6 150 16 8.9 16.0 16.0 12.0 1.0 31 30 0.0 -1.20 0.7
Summary
So, the above is all I want to share with you, and I hope you understand Describe in R better. If you have any questions, please leave a comment below, and I will answer your questions.
Good luck!
Maybe you are interested:
- The unite() function in R
- Aes Function In R: Construct Aesthetic Mappings
- How To Use count() Function In R

Hi, guys! My name’s Scott Miller. My current job is a software developer and I have shared a lot of quality articles about Javascript, C, C++, C#, Python, PHP, R, Java programming languages. I’m hoping they can assist you.
Name of the university: HCMUS
Major: IT
Programming Languages: C, C++, Python, R, Java, JavaScript