library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.8     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()

3.2.4

  1. My plots section of R studio has turned gray, other than that nothing has changed.
  2. 234 rows, 11 columns. Code:
mpg
## # A tibble: 234 × 11
##    manufacturer model      displ  year   cyl trans drv     cty   hwy fl    class
##    <chr>        <chr>      <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
##  1 audi         a4           1.8  1999     4 auto… f        18    29 p     comp…
##  2 audi         a4           1.8  1999     4 manu… f        21    29 p     comp…
##  3 audi         a4           2    2008     4 manu… f        20    31 p     comp…
##  4 audi         a4           2    2008     4 auto… f        21    30 p     comp…
##  5 audi         a4           2.8  1999     6 auto… f        16    26 p     comp…
##  6 audi         a4           2.8  1999     6 manu… f        18    26 p     comp…
##  7 audi         a4           3.1  2008     6 auto… f        18    27 p     comp…
##  8 audi         a4 quattro   1.8  1999     4 manu… 4        18    26 p     comp…
##  9 audi         a4 quattro   1.8  1999     4 auto… 4        16    25 p     comp…
## 10 audi         a4 quattro   2    2008     4 manu… 4        20    28 p     comp…
## # … with 224 more rows
## # ℹ Use `print(n = ...)` to see more rows
  1. The drv variable stands for the type of drive train, with f indicating front-wheel drive, r indicating real wheel drive, and 4 indicating 4wd.
ggplot(data = mpg) + geom_point(mapping = aes(x = cyl, y = hwy))

  1. The graph below is not very helpful as it doesn’t provide us with many points. As a result, we are unable to establish a relationship between the variables.
ggplot(mpg, aes(x = class, y = drv)) + geom_point()

3.3.1

  1. The points are not blue because the part of code where color is associated with blue is being treated as an aesthetic. As a result, color is now a variable that has been assigned the value “blue”.

  2. Categorical: manufacturer, class, trans, fl, drv, and model. Continuous: displ, hwy, cty, year, and cyl. When you run mpg, indicates to you that the data in that column is categorical. or indicated that the data in that column is continuous.

mpg
## # A tibble: 234 × 11
##    manufacturer model      displ  year   cyl trans drv     cty   hwy fl    class
##    <chr>        <chr>      <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
##  1 audi         a4           1.8  1999     4 auto… f        18    29 p     comp…
##  2 audi         a4           1.8  1999     4 manu… f        21    29 p     comp…
##  3 audi         a4           2    2008     4 manu… f        20    31 p     comp…
##  4 audi         a4           2    2008     4 auto… f        21    30 p     comp…
##  5 audi         a4           2.8  1999     6 auto… f        16    26 p     comp…
##  6 audi         a4           2.8  1999     6 manu… f        18    26 p     comp…
##  7 audi         a4           3.1  2008     6 auto… f        18    27 p     comp…
##  8 audi         a4 quattro   1.8  1999     4 manu… 4        18    26 p     comp…
##  9 audi         a4 quattro   1.8  1999     4 auto… 4        16    25 p     comp…
## 10 audi         a4 quattro   2    2008     4 manu… 4        20    28 p     comp…
## # … with 224 more rows
## # ℹ Use `print(n = ...)` to see more rows
  1. The stroke aesthetic modifys the width of the border.

3.6.1

  1. Line chart: gemo_line() #boxplot: geom_boxplot() #histogram: geom_histogram() #area chart: geom_area()

  2. I predict this code will give us a scatter plot with displ as the x variable and hwy as the y variable. This part of my predication was accurate when I ran the code, however I was not expecting each different variable to be a different color.

ggplot(data = mpg, mapping = aes(x = displ, y = hwy, colour = drv)) +
  geom_point() +
  geom_smooth(se = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

3.show.legend = FALSE hides the legend when the graph is produced. This was demonstrated when the author was talking about geom_smooth.

ggplot(data = mpg) +
  geom_smooth(mapping = aes(x = displ, y = hwy, colour = drv),show.legend = FALSE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

  1. When se is added to geom_smooth, it adds a visual to indicate standard error.
ggplot(data = mpg, mapping = aes(x = displ, y = hwy, colour = drv)) +geom_point() +geom_smooth(se = TRUE)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

  1. These two graphs will looks the same, as part of the code written in code #2 is inherited in code #1, meaning that although it was specified in code #2, it didn’t have to be to reach the same result.
ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
  geom_point() +
  geom_smooth()
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

ggplot() +
  geom_point(data = mpg, mapping = aes(x = displ, y = hwy)) +
  geom_smooth(data = mpg, mapping = aes(x = displ, y = hwy))
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'