Skip to content

Instantly share code, notes, and snippets.

@ryanburge
Last active March 6, 2017 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburge/36baa6a1e636f2c4101335c8951912da to your computer and use it in GitHub Desktop.
Save ryanburge/36baa6a1e636f2c4101335c8951912da to your computer and use it in GitHub Desktop.
Instructions for Class: 3/6/2017
Here's the data link:
simon <- read.csv(url("http://goo.gl/exQA14"))
Here's the link to the codebook:
http://opensiuc.lib.siu.edu/cgi/viewcontent.cgi?article=1010&context=ppi_statepolls
install.packages("dplyr")
install.packages("car")
install.packages("ggplot2")
install.packages("descr")
library(dplyr)
library(car)
library(ggplot2)
library(descr)
Here are some sample codes:
simon$downstate <- Recode(simon$area, "3=1; else=0")
black <- filter(simon, rac_eth == 2)
For more help with filtering here's a tutorial: https://ryanburge.github.io/blog/filter_practice/
ggplot(black, aes(area)) + geom_bar(fill = "red", colour = "black")
For more help with ggplot2 here's a tutorial: https://ryanburge.github.io/blog/ggplot2_tut/
Three tasks.
1. Create a variable that gives the actual age of each respondent. Make sure to deal with those who didn't respond.
2. Using filter, create a dataset of just cell users and another dataset of just landline users
3. Use ggplot to compare the age distribution of the two subsamples.
Then, we are going to learn about using Crosstabs and RMarkdown.
install.packages("rmarkdown")
library(rmarkdown)
Here's some syntax you are going to use in RMarkdown:
```{r message=FALSE, warning=FALSE}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment