---
title: "Week 3 Lecture 2"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(gapminder)
```

### ggplot

The following code is adapted from Kieran Healy's *Data Visualization*, Ch. 3. Please see the readings for exaplanations.

### First graph in ggplot

```{r}
p <- ggplot(data = gapminder,
            mapping = aes(x = gdpPercap,
                          y=lifeExp))
p + geom_point()
```


```{r}
p <- ggplot(data = gapminder,
            mapping = aes(x = gdpPercap,
                          y=lifeExp))
p +  geom_point() + geom_smooth(method="loess")
```


```{r}
p <- ggplot(data = gapminder,
            mapping = aes(x = gdpPercap,
                          y=lifeExp))
p + geom_point() + geom_smooth(method="loess") + scale_x_continuous(labels=scales::dollar)
```



```{r}
p <- ggplot(data = gapminder,
            mapping = aes(x = gdpPercap,
                          y=lifeExp))
p + geom_point() + geom_smooth(method="loess") + scale_x_log10()
```


```{r}
p <- ggplot(data = gapminder,
            mapping = aes(x = gdpPercap,
                          y=lifeExp))
p + geom_point() + geom_smooth(method="loess") + scale_x_log10(labels=scales::dollar)
```

