Descriptive statistics in R
Summarizing a sample's center and spread.
values <- c(12, 15, 15, 18, 21, 24, 24, 30, NA)
avg <- mean(values, na.rm = TRUE)
mid <- median(values, na.rm = TRUE)
spread <- sd(values, na.rm = TRUE)
variance <- var(values, na.rm = TRUE)
quartiles <- quantile(values, na.rm = TRUE)
iqr <- IQR(values, na.rm = TRUE)
span <- range(values, na.rm = TRUE)
overview <- summary(values)
How it works
mean,median,sd, andvarneedna.rmfor gaps.quantileandIQRdescribe the distribution's shape.summaryprints the five-number summary at once.
Keywords and builtins used here
IQRcmeanmedianquantilerangesdsummaryvar
The run, in numbers
- Lines
- 11
- Characters to type
- 333
- Tokens
- 98
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 65 seconds.
Step 1 of 3 in Describing, step 1 of 11 in Statistics.