Skip to main content
Module 3 · Lesson 2 of 26/18 in the course~22 min
Module lessons (2/2)

Data Exploration, NA and Aggregations

Lesson preview7 hands-on exercises readyCourse R · Module 3 — Functions, Apply and Descriptive Statistics

Calculate mean, median, sd, quantiles with na.rm = TRUE and summarize groups with tapply() and aggregate().

What you'll learn in this lesson

  • Calculate position indices (mean, median) and dispersion (sd, var, range, IQR) choosing between mean and median.
  • Defuse missing value propagation via na.rm = TRUE and na.omit().
  • Filter tables readably with subset() and summarize metrics by group with aggregate() and tapply().
  • Interpret the full output of summary() on numeric vectors and data frames.

Overview

Exploratory Data Analysis (EDA) answers three questions before you even build a graph or model: which values are typical, how much the observations vary, and whether there is anomalous or missing data (NA).

The arithmetic mean (mean) is highly affected by extreme values (outliers), while the median (median) represents the central value at 50% and is robust to asymmetries. If there is even just one NA, all of these functions return NA until you explicitly pass na.rm = TRUE.

Sections covered in this lesson

  1. 1Location, dispersion and na.rm = TRUE
  2. 2Filter and group in Base R: subset(), tapply() and aggregate()
  3. 3Test yourself: guided exercises
  4. 4Concept check
Pro Lesson · Module 3 — Functions, Apply and Descriptive Statistics

Unlock "Data Exploration, NA and Aggregations" and the full Course R curriculum

Calculate mean, median, sd, quantiles with na.rm = TRUE and summarize groups with tapply() and aggregate().

Unlock all 7 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Course R plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.