← Back to R Course | Chapter 10: Data Visualization | Lesson 2 of 7

hist()

In this page:

  1. hist()

hist()

hist(x) draws a histogram showing the frequency distribution of a numeric vector, automatically choosing sensible bin widths (or accept an explicit breaks argument). It's one of the fastest ways to visually inspect a dataset's distribution shape. Histograms are a first step in exploratory data analysis for any numeric variable.

Note: Pass breaks = n to hist() to control roughly how many bins the histogram uses.

Example: hist()

markup
set.seed(1)
values <- rnorm(100, mean = 50, sd = 10)

cat("Summary of values that hist() would visualize:\n")
print(summary(values))
cat("hist(values) would draw a histogram of this distribution\n")
🔒

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.