typestar

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

  1. mean, median, sd, and var need na.rm for gaps.
  2. quantile and IQR describe the distribution's shape.
  3. summary prints the five-number summary at once.

Keywords and builtins used here

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.

Type this snippet

Step 1 of 3 in Describing, step 1 of 11 in Statistics.

Next →

Descriptive statistics in other languages