---
title: "Explore and Visualize2"
author: "Prof. Eric A. Suess"
output:
  word_document: default
  html_document:
    df_print: paged
  html_notebook: default
  pdf_document: default
---

# Chapter 3 Data Visualization

4. Geometric shapes
5. Multiple smoothing lines
6. Statistical transformations

Today we are going to try some more code from Chapter 3 Data Visualization.

To start we will load the tidyverse.  Note that *ggplot2* is the first package loaded!

```{r message=FALSE}
library(tidyverse)
```

We will continue to work with the *mpg* dataset that is in the ggplot2 package.

```{r}
mpg
```


Make the scatterplot along with the smoothing line.

```{r echo=TRUE}
ggplot(data = mpg) + 
  geom_point(mapping = aes(x = displ, y = hwy)) + 
  geom_smooth(mapping = aes(x = displ, y = hwy))
```

Multiple smoothing lines.

```{r}
ggplot(data = mpg) + 
  geom_smooth(mapping = aes(x = displ, y = hwy, linetype = drv))
```


Statistical transformations

```{r}
ggplot(data = diamonds) + 
  geom_bar(mapping = aes(x = cut))
```

Proportions

```{r}
ggplot(data = diamonds) + 
  geom_bar(mapping = aes(x = cut, y = ..prop.., group = 1))
```

Position adjustment

```{r}
ggplot(data = diamonds) + 
  geom_bar(mapping = aes(x = cut, fill = clarity), position = "dodge")
```
