# Run this code to load the required packages
suppressMessages(suppressWarnings(suppressPackageStartupMessages({
library(mosaic)
library(supernova)
library(Lock5withR)
})))
# Adjust the plots to be a bit smaller
options(repr.plot.width = 6, repr.plot.height = 4)
CensusSchool <- read.csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vSVaWnM4odSxy0mlnhWvvGbeLtiKoZmsbqC6KLzXtBOjQfrF9EVKuX4RVh3XbP3iw/pub?gid=2100178416&single=true&output=csv", header = TRUE)
str(CensusSchool)
select(CensusSchool, Home_Internet_Access, Schoolwork_Pressure) -> Internet_vs_Pressure
filter(CensusSchool, Home_Internet_Access != "NA", Schoolwork_Pressure != "NA") -> Internet_vs_Pressure
BarGraph <- gf_bar(~ Schoolwork_Pressure, data = Internet_vs_Pressure, fill = "pink") %>%
gf_facet_grid(Home_Internet_Access ~ .)
#BarGraph + coord_flip()
recode(Internet_vs_Pressure$Home_Internet_Access, "No internet connection" = "No Int.") -> Internet_vs_Pressure$Home_Internet_Access
recode(Internet_vs_Pressure$Home_Internet_Access, "Yes - broadband connection" = "Y-Broadband") -> Internet_vs_Pressure$Home_Internet_Access
recode(Internet_vs_Pressure$Home_Internet_Access, "Yes - dial-up connection" = "Y-Dial-Up") -> Internet_vs_Pressure$Home_Internet_Access
recode(Internet_vs_Pressure$Home_Internet_Access, "Yes - other" = "Y-Other") -> Internet_vs_Pressure$Home_Internet_Access
recode(Internet_vs_Pressure$Schoolwork_Pressure, "None"= "1-None", "Very little" = "2-Very Little" , "Some" = "3-Some", "A lot" = "4-A Lot") -> Internet_vs_Pressure$Schoolwork_Pressure
gf_bar(~ Schoolwork_Pressure, data = Internet_vs_Pressure, fill = "pink") %>% gf_facet_grid(Home_Internet_Access ~ .) -> BarGraph
BarGraph + coord_flip()
as.numeric(Internet_vs_Pressure, Schoolwork_Pressure) -> Internet_vs_Pressure$Schoolwork_PressNum
filter(Internet_vs_Pressure, Schoolwork_Pressure != "NA") -> Internet_vs_Pressure$Schoolwork_PressNum
lm(SchoolPresNum ~ Home_Internet_Access, data = Internet_vs_Pressure) -> IntPres.model
predict(IntPres.model) -> Internet_vs_Pressure$IntPresPredict
gf_jitter(SchoolPresNum ~ Home_Internet_Access, data = Internet_vs_Pressure, color = "blue") %>%
gf_point(IntPresPredict ~ Home_Internet_Access, data = Internet_vs_Pressure, color = "red")
confint(IntPres.model)