Skip to content

Commit

Permalink
adding paper draft
Browse files Browse the repository at this point in the history
  • Loading branch information
haleyjeppson committed May 5, 2017
1 parent 891f491 commit 17ff23e
Show file tree
Hide file tree
Showing 14 changed files with 1,785 additions and 386 deletions.
1 change: 0 additions & 1 deletion inst/asa.bst

This file was deleted.

35 changes: 0 additions & 35 deletions inst/asa.sty

This file was deleted.

92 changes: 82 additions & 10 deletions inst/flydata.R
@@ -1,10 +1,11 @@
library(tidyverse)
library(forcats)
library(curl)

fly <- read.csv( curl("https://raw.githubusercontent.com/fivethirtyeight/data/master/flying-etiquette-survey/flying-etiquette.csv") ,
na.strings=c(""," ","NA"))
fly <- read_csv( curl("https://raw.githubusercontent.com/fivethirtyeight/data/master/flying-etiquette-survey/flying-etiquette.csv"))

names(fly) <- c("ID", "FlightFreq", "DoYouRecline", "Height", "Child18",
"3SeatsWhoUses2Arms", "2SeatsWhoUses1Arm", "WhoControlsWindowShade",
"Seats3_2Arms", "Seats2_1Arm", "WhoControlsWindowShade",
"RudeToMoveToUnsoldSeat", "RudeToTalkToNeighbor",
"6hrFlightRudeToLeaveSeat", "RecliningObligationToBehind",
"RudeToRecline", "EliminateReclining", "RudeToSwitchSeatsForFriends",
Expand All @@ -14,16 +15,87 @@ names(fly) <- c("ID", "FlightFreq", "DoYouRecline", "Height", "Child18",
"HaveYouSmoked", "Gender", "Age", "HouseholdIncome", "Education", "Region")


set.separators(c(":", ";","|"))
ggplot(data = fly) + geom_mosaic(aes(x=product(DoYouRecline)))
ggplot(data = fly) + geom_mosaic(aes(x=product(Height), fill=RudeToRecline), offset=0.005, na.rm=T)
fly$DoYouRecline <- fct_relevel(fly$DoYouRecline, c("Always", "Usually", "About half the time", "Once in a while"))
fly$RudeToRecline <- fct_relevel(fly$RudeToRecline, c("Yes, very rude", "Yes, somewhat rude"))
fly$FlightFreq <- fct_relevel(fly$FlightFreq, c("Every day", "A few times per week" , "A few times per month","Once a month or less", "Once a year or less" ,"Never" ) )
levels(fly$RecliningObligationToBehind) <- c("No", "Yes")

ggplot(data = fly) + geom_mosaic(aes(x=product(Gender, Child18), fill=RudeToBringBaby), offset=0.005)
fly$HouseholdIncome <- fct_relevel(fly$HouseholdIncome,
c( "$0 - $24,999" ,"$25,000 - $49,999",
"$50,000 - $99,999" ,
"$100,000 - $149,999", "150000"))
levels(fly$HouseholdIncome)[5]<- "150,000 or more"

ggplot(data = fly) + geom_mosaic(aes(x=product(RudeToRecline), fill=DoYouRecline), na.rm=T)
library(ggplot2)
library(ggmosaic)
library(ggthemes)
library(ggsci)
head(fly)
str(fly)

ggplot(data = fly) + geom_mosaic(aes(x=product(DoYouRecline), fill=RudeToRecline), na.rm=T)


ggplot(data = fly) + geom_mosaic(aes(x=product(Child18), fill=RudeToBringBaby), na.rm=T, offset=0.005)
ggplot(data = fly) + geom_mosaic(aes(x=product(RudeToRecline), fill=DoYouRecline), na.rm=T) +
scale_fill_locuszoom()+theme_hc() + theme(axis.text.y = element_blank())+
labs(title="Rude to recline? vs. Do you recline?", y="Do you recline?", x="Rude to recline?") #+coord_flip()

mosaicplot(~RudeToRecline + DoYouRecline, data= fly, color=DoYouRecline2)
getPalette <- colorRampPalette(pal_locuszoom("default")(5))
DoYouRecline2 <- getPalette(5)
names(DoYouRecline2) <- levels(fly$DoYouRecline)
mosaic(~RudeToRecline + DoYouRecline, data= fly, gp = gpar(fill = DoYouRecline2))



ggplot(data = fly) + geom_mosaic(aes(x=product(RudeToRecline), fill=DoYouRecline), na.rm=T) +
scale_fill_locuszoom()+theme_hc() + theme(axis.text.y = element_blank())+
labs(title="Rude to recline? vs. Do you recline?", y="Do you recline?", x="Rude to recline?")


ggplot(data = fly) + geom_mosaic(aes(x=product(DoYouRecline), fill=RudeToRecline), na.rm=T)+
scale_fill_locuszoom()+theme_hc() +labs(title="Rude to recline? vs. Do you recline?", x="Do you recline?", y="Rude to recline?")


ggplot(data = fly) + geom_mosaic(aes(x=product(Child18), fill=RudeToBringBaby), na.rm=T, offset=0.005) +
scale_fill_locuszoom()+theme_hc() +
labs(title="Is it rude to bring a baby onboard?", x="Has child under age 18", y="Rude to bring baby?")



ggplot(data = fly) + geom_mosaic(aes(x=product(RudeToRecline), fill=DoYouRecline), na.rm=T)+coord_flip()+
scale_fill_locuszoom()+theme_hc() +
labs(title="Rude to recline? vs. Do you recline?", y="Do you recline?", x="Rude to recline?")


ggplot(data = fly) + geom_mosaic(aes(x=product(FlightFreq), fill=RudeToTalkToNeighbor), na.rm=T) +
guides(fill=guide_legend( reverse = TRUE)) +
scale_fill_locuszoom()+theme_hc()

ggplot(data = fly) + geom_mosaic(aes(x=product(RudeToRecline), fill=RecliningObligationToBehind), na.rm=T) +
labs(x="Is it rude to recline?", title="If reclining, do you have an obligation to the person behind?") +
scale_fill_locuszoom()+theme_hc()

ggplot(data = fly) + geom_mosaic(aes(x=product(RudeToRecline), fill=EliminateReclining), na.rm=T) +
labs(x="Is it rude to recline?", title="Should reclining be eliminated?") +
scale_fill_locuszoom()+theme_hc()

ggplot(data = fly) + geom_mosaic(aes(x=product(Age), fill=RudeToBringUnrulyChild),
divider=ddecker(), na.rm=T) +
scale_fill_locuszoom()+theme_hc()

ggplot(data = fly) +
geom_mosaic(aes(x=product(FlightFreq), fill=DoYouRecline), na.rm=T) +
scale_fill_locuszoom()+theme_hc()

ggplot(data = fly) +
geom_mosaic(aes(x=product(Height), fill=RudeToRecline), na.rm=T) +
scale_fill_locuszoom()+theme_hc()


ggplot(data = fly) +
geom_mosaic(aes(x=product(HouseholdIncome), fill=FlightFreq), na.rm=T) +
scale_fill_locuszoom()+theme_hc()

ggplot(data = fly) +
geom_mosaic(aes(x=product(Seats3_2Arms), fill=WhoControlsWindowShade), na.rm=T) +
scale_fill_locuszoom()+theme_hc()
4 changes: 0 additions & 4 deletions inst/flying-concordance.tex

This file was deleted.

0 comments on commit 17ff23e

Please sign in to comment.