← Back to R Course | Chapter 9: Statistics | Lesson 3 of 7

summary()

summary gives a quick report card for your data, showing key facts like the smallest, middle, and biggest values. It helps you get to know a dataset in one line.

In this page:

  1. summary()
Syntax
r
summary(x)
summary(df)

summary()

summary() produces a quick statistical overview of a numeric vector or data frame -- minimum, 1st quartile, median, mean, 3rd quartile, and maximum.

Applied to a whole data frame, it summarizes every column at once. It's usually the very first function run after loading a new dataset to get a quick sense of its shape.

Note: summary(df) run on a whole data frame gives you a quick per-column overview in one call.

Example: summary()

markup
values <- c(23, 5, 67, 12, 45, 30, 8)

print(summary(values))
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Expecting summary() to return only numbers, when for a factor or character it gives counts or class information.
  2. Forgetting that summary() on a vector with NA shows a separate NA's count while the other stats ignore them.
  3. Assuming the Mean and Median are the same value, when a large gap between them shows skewed data.
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.