CommencerCommencer gratuitement

Faceted histogram

In this chapter, you'll be working with the cars dataset, which records characteristics on all of the new models of cars for sale in the US in a certain year. You will investigate the distribution of mileage across a categorical variable, but before you get there, you'll want to familiarize yourself with the dataset.

Cet exercice fait partie du cours

Exploratory Data Analysis in R

Afficher le cours

Instructions

The cars dataset has been loaded in your workspace.

  • Load the ggplot2 package.
  • View the size of the data and the variable types using str().
  • Plot a histogram of city_mpg faceted by suv, a logical variable indicating whether the car is an SUV or not.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Load package


# Learn data structure


# Create faceted histogram
ggplot(cars, aes(x = ___)) +
  geom_histogram() +
  facet_wrap(~ ___)
Modifier et exécuter le code