IniziaInizia gratis

Adding geometries

The diamonds dataset contains details of 1,000 diamonds. Among the variables included are carat (a measurement of the diamond's size) and price.

You'll use two common geom layer functions:

  • geom_point() adds points (as in a scatter plot).
  • geom_smooth() adds a smooth trend curve.

As you saw previously, these are added using the + operator.

ggplot(data, aes(x, y)) +
  geom_*()

Where * is the specific geometry needed.

Questo esercizio fa parte del corso

Introduction to Data Visualization with ggplot2

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Explore the diamonds data frame with str()
___
Modifica ed esegui il codice