Skip to content

Instantly share code, notes, and snippets.

program
@r-conway
r-conway / Book.r
Created September 16, 2016 14:33
Book Assignment
#Enter variables
titles<-c("The Waste Land", "Lord of the Flies", "Grapes of Wrath", "Pride and Prejudice", "Frankenstein", "Little Women", "Jane Eyre", "The Things they Carried", "Huckleberry Finn", "The Old Man and the Sea")
author<-c("Thomas Eliot", "William Golding", "John Steinbeck", "Jane Austen", "Mary Shelley", "Louisa May Alcott", "Charlotte Bronte", "Tim O'Brien", "Mark Twain", "Ernest Hemmingway")
pyear<-c(1922, 1954, 1939, 1813, 1818, 1868, 1847, 1990, 1884, 1952)
stock<-c(12, 4, 7, 1, 8, 9, 3, 2, 17, 5)
price<-c(5.50, 10, 12, 20, 18.50, 22, 16, 25, 8, 15)
#create dataframe
books<-data.frame(titles, author, pyear, stock, price)
@r-conway
r-conway / year_race
Last active September 23, 2016 17:26
library(dplyr)
library(readr)
library(tidyr)
#enter data
a <- read_csv('./data/usa_00001.csv')
#we should remove all data from alask and hawaii
aa <- a %>% filter(!(YEAR < 1960 & STATEFIP %in% c(2,15)))
#code number for race into words using factor
library(dplyr)
library(readr)
library(ggplot2)
library(RColorBrewer)
#read in data
a<- read_csv('./data/usa_00005.csv')
#remove Hawaii and Alaska and pick out those of working age
b<- a %>% filter(AGE>=15 & AGE<=65 & !(STATEFIP %in% c(2,15)))
library(dplyr)
library(readr)
library(ggplot2)
library(RColorBrewer)
#read in data
a<- read_csv('./data/usa_00005.csv')
#remove Hawaii and Alaska and pick out those of working age
b<- a %>% filter(AGE>=15 & AGE<=65 & !(STATEFIP %in% c(2,15)))
#load packages
library(readr)
library(dplyr)
library(ggplot2)
library(RColorBrewer)
#REad in data
a <- read_csv('./data/usa_00006.csv')
#filter so we're only taking from german, austira, and hungary, both first and second generation
a2<-a%>%filter(BPL==453 | BPL==454 | BPL==450 | MBPL==453 | MBPL==454 | MBPL== 450 | FBPL==453 | FBPL==454 | FBPL==450)
@r-conway
r-conway / 10.13.r
Last active October 17, 2016 17:53
#load library
library(readr)
library(dplyr)
library(ggplot)
library(RColorBrewer)
library(ggmap)
library(maptools)
library(gtools)
#Clear Enviornment
rm(list=ls())
@r-conway
r-conway / fig1FP.r
Last active November 15, 2016 17:02
#load libraries
library(readr)
library(dplyr)
library(ggplot2)
library(RColorBrewer)
library(scales)
#load data
a <- read_csv('data/usa_00013(1).csv',col_types=cols(PERWT=col_double()))
@r-conway
r-conway / fig2A.r
Last active October 24, 2016 16:54
#line graph for race for single women
#load libraries
library(readr)
library(dplyr)
library(ggplot2)
library(RColorBrewer)
library(scales)
#load data
@r-conway
r-conway / fig3FP.r
Last active October 24, 2016 17:17
#We want to make 2 line graphs, one for married and this one for single with lines for number of children
#load libraries
library(readr)
library(dplyr)
library(ggplot2)
library(RColorBrewer)
library(scales)
#load data