&nbsp;

```{r setup, echo=FALSE, eval=TRUE, message=F, warning=F}
library(tidyverse)

SCP16 <- readRDS(url("http://posc3410.svmiller.com/toy-data/SCP16.rds"))
```

*1\. Get the mean of the percentage of the vote Trump got in the primary. Get the median. What does this suggest in terms of skew of the variable?*

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras aliquet est sapien, at mollis sapien sollicitudin in. Duis vel maximus tellus. The mean is `r round(mean(SCP16$trump), 3) `. The median is `r round(median(SCP16$trump), 3)`. The difference between the two is `r round(mean(SCP16$trump), 3)- round(median(SCP16$trump), 3)`, which is not a lot.

*2\. Get a density plot of the Trump share variable. What does this suggest about the distribution of this variable?*

```{r plottrump, echo=FALSE, eval=TRUE}
SCP16 %>%
  ggplot(.,aes(trump)) + geom_density() +
  scale_x_continuous(limits=c(20,60))

```

Nullam odio nibh, finibus et nibh in, pulvinar hendrerit est. Phasellus euismod varius erat in euismod. Vivamus id ipsum vulputate, rhoncus lectus ut, luctus orci.

*3\. Look at the mean of the population variable and then look at the median. Get a density plot too. What does this suggest in terms of skew of the variable?*

Sed consectetur sem quis massa facilisis, et sodales ligula aliquet. Praesent nec dui varius nulla ultricies molestie. The mean is `r round(mean(SCP16$population), 3)` while the median is `r round(median(SCP16$population), 3)`. Here's the density plot you wanted.

```{r plotpop, echo=FALSE, eval=TRUE}
SCP16 %>%
  ggplot(.,aes(population)) + geom_density() +
  scale_x_continuous(labels = scales::comma)

```

*4\. Why do you think the population variable has this distribution?*

Suspendisse lacinia quis leo sit amet ullamcorper. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae.

*5\. Take a natural logarithm of the population variable and then get the mean and median again. Get a density plot too. What do you see?*

```{r makelog, echo=FALSE, eval=TRUE}
SCP16$logpop <- log(SCP16$population)
```

The mean is `r round(mean(SCP16$logpop), 3)` and the median is `r round(median(SCP16$logpop), 3)`.

```{r plologpop, echo=FALSE, eval=TRUE}
SCP16 %>%
  ggplot(.,aes(logpop)) + geom_density() +
  scale_x_continuous(limits=c(8,14))
```

## Extra Credit

*6.\ Run the regression that seeks a minimal model to explain the county-level vote share for Trump in the Republican primary. What do you think these results suggest? Be mindful of ecological fallacies.*

```{r regression, echo=FALSE, eval=TRUE}
summary(M1 <- lm(trump ~ illiteracy +  unemployment + perblack, SCP16))

```