# Run this code to load the required packages
suppressMessages(suppressWarnings(suppressPackageStartupMessages({
library(mosaic)
library(supernova)
library(Lock5withR)
})))
CensusSchool <- read.csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vSVaWnM4odSxy0mlnhWvvGbeLtiKoZmsbqC6KLzXtBOjQfrF9EVKuX4RVh3XbP3iw/pub?gid=2100178416&single=true&output=csv", header = TRUE)
str(CensusSchool)
head(CensusSchool)
mygraph <- gf_bar(~ Schoolwork_Pressure , data = CensusSchool)
mygraph <- gf_histogram(~ Doing_Homework_Hours , data = CensusSchool)
mydataset<-(select(CensusSchool, Doing_Homework_Hours, Schoolwork_Pressure))
head(mydataset)
filter(mydataset,Doing_Homework_Hours<= 25,Doing_Homework_Hours>=0)-> mydataset2
na.omit(mydataset2)->mydataset3
mydataset3$Schoolwork_Pressure<-factor(mydataset3$Schoolwork_Pressure, labels = c("Alot","Some","Very little", "None"))
gf_histogram(~Doing_Homework_Hours,data= mydataset3, fill = "salmon", color = "black") %>%
gf_facet_grid(Schoolwork_Pressure ~.)
gf_histogram(~Doing_Homework_Hours, data = mydataset3, fill = "forestgreen", color = "black", bins = 5)%>%
gf_facet_grid(Schoolwork_Pressure ~.) -> histogram1
histogram1+coord_flip()
lm(Doing_Homework_Hours ~Schoolwork_Pressure, data = mydataset3)
lm(Doing_Homework_Hours ~Schoolwork_Pressure, data = mydataset3)->homework_model
anova(homework_model)
homework_model <- lm(Doing_Homework_Hours ~ Schoolwork_Pressure, data = mydataset3)
mydataset3$predictions <- predict(homework_model)
gf_jitter(Doing_Homework_Hours ~ Schoolwork_Pressure, data = mydataset3, width = .2, color = "black", alpha = .4, size = 1) %>%
gf_jitter(predictions ~ Schoolwork_Pressure, data = mydataset3, color = "pink", size = 2, height = 0, width =.2)
confint(homework_model)
sdof <- do(1000) * fVal(Doing_Homework_Hours ~ shuffle(Schoolwork_Pressure), data = CensusSchool)
gf_histogram(~ fVal, data = sdof) %>%
gf_point(0 ~ fVal(Doing_Homework_Hours ~ Schoolwork_Pressure, data = CensusSchool))