Last active
March 19, 2017 02:11
-
-
Save ryanburge/fdf67df80cd95b2390ccd5edfb40909e to your computer and use it in GitHub Desktop.
Instructions for Class on March 20, 2017
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## RUN ALL THIS SYNTAX BEFORE WE START | |
## This will install and load all the packages you need for class today. | |
ipak <- function(pkg){ | |
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] | |
if (length(new.pkg)) | |
install.packages(new.pkg, dependencies = TRUE) | |
sapply(pkg, require, character.only = TRUE) | |
} | |
packages <- c("ggplot2", "dplyr", "car", "Rmisc") | |
ipak(packages) | |
## STOP AND WAIT FOR ME | |
salary <- data.frame("name" =c("Bill Gates", "Warren Buffett", "Donald Trump", "Bob", "Steve", "Lisa", "Karen", "David Glassman", "Ben", "Piper", "Hope"), | |
money = c(10000000,12000000,2000000, 42000,35000,54000,27500,400000,33000, 75000, 87000)) | |
## Let's learn about dplyr's arrange command | |
## How do we put things in a descending order? | |
## How about some filter practice. Create a smaller dataset of just people who aren't rich. | |
## Let's learn a little about mean, median, and standard deviation. | |
## Let's say that you wanted to find out what the average salary was for women vs. men. | |
salary$gender <- c("M", "M", "M", "F", "F", "M", "M", "F", "F", "M", "M", "F", "F") | |
## Here's a dataset of heights and weights | |
pop <- read.csv(url("https://goo.gl/PPrmeY")) | |
## Let's do some work on their means, medians, and standard deviations. | |
## NOW LOAD IN A NEW DATASET | |
cces <- read.csv(url("https://goo.gl/Ukt2xt")) | |
## Here's the codebook | |
https://dataverse.harvard.edu/file.xhtml?fileId=3004424&version=1.2 | |
## Tell me which gender has, on average, a higher level of education | |
## Now, tell me which gender, on average, has a higher household income | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment