Workshop Assignment

Author

Felix Walther

Question 3

Create a scatterplot showing the relationship between bill_length_mm and bill_depth_mm using the penguins dataset. Describe the relationship.


Load requisite packages:

library(tidyverse)
library(palmerpenguins)

Map the data:

ggplot(
  data = penguins,
  mapping = aes(x = bill_length_mm, y = bill_depth_mm)
) +
  geom_point()

Interpretation:

The relationship between the variables appears to show a positive association. As bill length increases, bill depth tends to increase as well. However, there are distinct clusters in the scatterplot, likely due to different penguin species in the data set.


Question 5

Run the following code and explain why it produces an error.

ggplot(data = penguins) + 
  geom_point()

Explanation:

The error occurs because no aesthetic mappings (aes()) are provided. Since neither an x nor y variable is specified, ggplot() does not know what variables to plot, so a scatterplot cannot be generated.