Descriptive Statistics

Summarise your data with means, standard deviations, and grouped summaries.

Basics (when to use cat(), signif(), round())

Use these three together when reporting results clearly:

  • cat() for readable text output
  • signif() for significant digits (good for scientific reporting)
  • round() for fixed decimal places (good for tables)
Frequency & Distribution

count()

Use count() to build a quick frequency table. This is useful when you want exact counts for each category.

Barchart

A bar chart visualizes categorical frequencies. Use it to compare how many observations belong to each group.

Histogram

A histogram visualizes the distribution of a numeric variable. Use it to see where values cluster and how spread out they are.

Central Tendency

Central tendency describes the “typical” value in a dataset. The two most common measures are mean and median.

  • Mean: arithmetic average of all values
  • Median: middle value after sorting the data

If the distribution is fairly symmetric, mean and median are often similar. If there are outliers or strong skew, the median usually reflects the center better.

Mean

Use the mean when you want to include all observations in the summary. Because every value contributes, extreme values can pull it up or down.

Median

Use the median when you want a robust center that is less affected by outliers. It is often preferred for skewed data.

Variability

Variability describes how spread out values are around the center. Use these measures together to understand both total spread and typical spread.

Extrema

Use min() and max() to report range endpoints. They are useful for quickly spotting the lowest and highest observed values.

Standard deviation

Standard deviation (sd) is the typical distance of values from the mean. A larger SD means values are more dispersed.

Variance

Variance (var) is the squared version of spread around the mean. It is less intuitive than SD but important in many statistical methods.

Quantiles & Interquartile range (IQR)

IQR shows the spread of the middle 50% of the data. Quantiles provide cut points (for example 25%, 50%, and 75%). These are robust to outliers compared with range-based measures.

summarize()

Use summarize() for whole-table summaries, and combine with group_by() for per-group summaries.

Anscombe’s Quartet (why plots matter)

Anscombe’s quartet is a classic example showing that datasets can have almost identical descriptive statistics while looking very different when plotted.

The four datasets have nearly the same:

  • mean of x and y
  • variance of x and y
  • correlation between x and y
  • linear regression line

But each dataset has a different pattern (linear trend, curvature, outlier-driven relation, or vertical cluster). This is why descriptive statistics should be paired with visualization, not used alone.