---
title: "Lab 01 - Hello R"
output: html_document
---

### Load packages

```{r load-packages, message=FALSE}
library(tidyverse) 
library(datasauRus)
```


### Exercise 1

Based on the help file, how many rows and how many columns does the `datasaurus_dozen` file have? What are the variables included in the data frame? Add your responses to your lab report. When you're done, commit your changes with the commit message "Added answer for Ex 1", and push.

#### Solution

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

### Exercise 2

Plot `y` vs. `x` for the `dino` dataset. Then, calculate the correlation coefficient between x and y for this dataset.

#### Solution

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

```{r plot-dino, fig.height=3, fig.width=6}
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:

```{r cor-dino}
dino_data %>%
  summarize(r = cor(x, y))
```



### Exercise 3

Plot `y` vs. `x` for the `star` dataset. You can (and should) reuse code we introduced above, just replace the dataset name with the desired dataset. Then, calculate the correlation coefficient between x and y for this dataset. How does this value compare to the r of dino?

#### Solution

```{r plot-star, fig.height=3, fig.width = 6}
star_data <- datasaurus_dozen %>%
  filter(dataset == "star")

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

```{r cor-star}
star_data %>%
  summarize(r = cor(x, y))
```
