library(tidyverse)
library(datasauRus)

Exercise 1

Solution

2 columns, 13 rows, 3 variables: dataset: indicates which dataset the data are from x: x-values y: y-values

Exercise 2

Solution

First let’s plot the data in the dino dataset:

dino_data <- datasaurus_dozen %>%
  filter(dataset == "dino")

ggplot(data = dino_data, mapping = aes(x = x, y = y)) +
  geom_point()

And next calculate the correlation between x and y in this dataset:

dino_data %>%
  summarize(r = cor(x, y))
## # A tibble: 1 x 1
##         r
##     <dbl>
## 1 -0.0645

Exercise 3

Solution

star_data <- datasaurus_dozen %>%
  filter(dataset == "star")

ggplot(data = star_data, mapping = aes(x = x, y = y)) +
  geom_point()

star_data %>%
  summarize(r = cor(x, y))
## # A tibble: 1 x 1
##         r
##     <dbl>
## 1 -0.0630