# 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)
gf_jitter(Watching_TV_Hours ~ Gender, data = CensusSchool, color = "black")
gf_jitter(Work_At_Home_Hours ~ Gender, data = CensusSchool, color = "green")
gf_point(Watching_TV_Hours ~ Gender, data = CensusSchool, color = "black")
gf_point(Watching_TV_Hours ~ Gender, data = CensusSchool, color = "green")
CensusSchool <- filter(CensusSchool, Watching_TV_Hours <= 24*7)
CensusSchool <- filter(CensusSchool, Work_At_Home_Hours <= 24*7)
CensusSchool <- filter(CensusSchool, Gender!= "NA")
gf_point(Watching_TV_Hours ~ Gender, data = CensusSchool, color = "black")
gf_point(Work_At_Home_Hours ~ Gender, data = CensusSchool, color = "green")
CensusSchool <- filter(CensusSchool, Watching_TV_Hours <= 24*7)
CensusSchool <- filter(CensusSchool, Work_At_Home_Hours <= 24*7)
CensusSchool <- filter(CensusSchool, Gender!= "NA")
gf_jitter(Watching_TV_Hours ~ Gender, data = CensusSchool, color = "black")
gf_jitter(Work_At_Home_Hours ~ Gender, data = CensusSchool, color = "green")
CensusSchool <- filter(CensusSchool, Watching_TV_Hours <= 16*7)
CensusSchool <- filter(CensusSchool, Work_At_Home_Hours <= 16*7)
CensusSchool <- filter(CensusSchool, Gender!= "NA")
gf_jitter(Watching_TV_Hours ~ Gender, data = CensusSchool, color = "black", alpha = .3) %>%
gf_boxplot( color = "dark green", alpha = .1, size = .5)
gf_jitter(Work_At_Home_Hours ~ Gender, data = CensusSchool, color = "black", alpha = .3) %>%
gf_boxplot(color = "dark blue", alpha = .1, size = .5)
Work.model <- lm(Work_At_Home_Hours ~ Gender, data = CensusSchool)
Work.model
TV.model <- lm(Watching_TV_Hours ~ Gender, data = CensusSchool)
TV.model
CensusSchool <- filter(CensusSchool, Work_At_Home_Hours <= 16*7)
CensusSchool <- filter(CensusSchool, Gender!= "NA")
lm(Work_At_Home_Hours ~ NULL, data = CensusSchool)-> Empty_model
predict(Empty_model)-> CensusSchool$Empty.Pred
head(CensusSchool)
gf_jitter(Work_At_Home_Hours ~ Gender, data = CensusSchool, width = .2) %>%
gf_jitter(predict(Work.model) ~ Gender, color = "magenta", height = 0)
CensusSchool <- filter(CensusSchool, Watching_TV_Hours <= 16*7)
CensusSchool <- filter(CensusSchool, Gender!= "NA")
lm(Watching_TV_Hours ~ NULL, data = CensusSchool)-> Empty_model
predict(Empty_model)-> CensusSchool$Empty.Pred
head(CensusSchool)
gf_jitter(Watching_TV_Hours ~ Gender, data = CensusSchool, width = .2) %>%
gf_jitter(predict(TV.model) ~ Gender, color = "magenta", height = 0)
supernova(Work.model)
supernova(TV.model)