Based on Book by Leland Wilkinson
Elements :
Data : the dataset to be plotted.
Aesthetics : The scale on which we map our data
Geometrics : The visual elements used for our data.
Facets : Plotting small multiples
Statistics : Representation of our data to aid understanding.
Coordinates : The space on which the data will be plotted.
Themes : All non data ink.
These are building blocks.
# A scatter plot has been made for you
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point()
# Replace ___ with the correct vector
ggplot(mtcars, aes(x = wt, y = mpg, col = disp)) +
geom_point()
# Replace ___ with the correct vector
ggplot(mtcars, aes(x = wt, y = mpg, size = disp)) +
geom_point()
# Explore the diamonds data frame with str()
str(diamonds)
# Add geom_point() with +
ggplot(diamonds, aes(x = carat, y = price))+geom_point()
# Add geom_point() and geom_smooth() with +
ggplot(diamonds, aes(x = carat, y = price))+geom_point()+geom_smooth()
# The plot you created in the previous exercise
ggplot(diamonds, aes(x = carat, y = price)) +
geom_point() +
geom_smooth()
# Copy the above command and assign the correct value to col in aes()
ggplot(diamonds, aes(x = carat, y = price, col = clarity)) +
geom_smooth()
# Keep the color settings from previous command. Plot only the points with argument alpha.
ggplot(diamonds, aes(x = carat, y = price, col = clarity)) +
geom_point(alpha = 0.4)
# Create the object containing the data and aes layers: dia_plot
dia_plot <- ggplot(diamonds, aes(x = carat, y = price))
# Add a geom layer with + and geom_point()
dia_plot+geom_point()
# Add the same geom layer, but with aes() inside
dia_plot+geom_point(aes(col=clarity))
Elements :
Data : the dataset to be plotted.
Aesthetics : The scale on which we map our data
Geometrics : The visual elements used for our data.
Facets : Plotting small multiples
Statistics : Representation of our data to aid understanding.
Coordinates : The space on which the data will be plotted.
Themes : All non data ink.
These are building blocks.
# A scatter plot has been made for you
ggplot(mtcars, aes(x = wt, y = mpg)) +
geom_point()
# Replace ___ with the correct vector
ggplot(mtcars, aes(x = wt, y = mpg, col = disp)) +
geom_point()
# Replace ___ with the correct vector
ggplot(mtcars, aes(x = wt, y = mpg, size = disp)) +
geom_point()
# Explore the diamonds data frame with str()
str(diamonds)
# Add geom_point() with +
ggplot(diamonds, aes(x = carat, y = price))+geom_point()
# Add geom_point() and geom_smooth() with +
ggplot(diamonds, aes(x = carat, y = price))+geom_point()+geom_smooth()
# The plot you created in the previous exercise
ggplot(diamonds, aes(x = carat, y = price)) +
geom_point() +
geom_smooth()
# Copy the above command and assign the correct value to col in aes()
ggplot(diamonds, aes(x = carat, y = price, col = clarity)) +
geom_smooth()
# Keep the color settings from previous command. Plot only the points with argument alpha.
ggplot(diamonds, aes(x = carat, y = price, col = clarity)) +
geom_point(alpha = 0.4)
# Create the object containing the data and aes layers: dia_plot
dia_plot <- ggplot(diamonds, aes(x = carat, y = price))
# Add a geom layer with + and geom_point()
dia_plot+geom_point()
# Add the same geom layer, but with aes() inside
dia_plot+geom_point(aes(col=clarity))
set.seed(1)
# The dia_plot object has been created for you
dia_plot <- ggplot(diamonds, aes(x = carat, y = price))
# Expand dia_plot by adding geom_point() with alpha set to 0.2
dia_plot <- dia_plot +
geom_point(alpha = 0.2)
# Plot dia_plot with additional geom_smooth() with se set to FALSE
dia_plot + geom_smooth(se = FALSE)
# Copy the command from above and add aes() with the correct mapping to geom_smooth()
dia_plot + geom_smooth(aes(col = clarity), se = FALSE)
Comments
Post a Comment