# 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)
CensusSchool
head(CensusSchool)
select(CensusSchool, Watching_TV_Hours, ClassGrade)
filter(CensusSchool,Watching_TV_Hours<= 25,Watching_TV_Hours> -1)-> CensusSchool2
gf_histogram(~Watching_TV_Hours,data= CensusSchool2, fill = "blue", color = "black") %>% gf_facet_grid(ClassGrade ~.)
CensusSchool2 <- select(CensusSchool2, Watching_TV_Hours, ClassGrade)
CensusSchool2 <- filter(CensusSchool2, Watching_TV_Hours != "NA", ClassGrade !="NA")
filter(CensusSchool2,Watching_TV_Hours<= 25,Watching_TV_Hours> -1)-> CensusSchool2
gf_histogram(~Watching_TV_Hours,data= CensusSchool2, fill = "red", color = "black")
gf_bar(~ClassGrade, data = CensusSchool2 , fill= "blue", color= "black", bins = 30)
gf_bar(~ ClassGrade, data = CensusSchool2) -> bargraph
bargraph + coord_flip ()
lm(Watching_TV_Hours~ClassGrade,data=CensusSchool2)->Census.Model
predict(Census.Model)
lm(Watching_TV_Hours ~ ClassGrade, data = CensusSchool2)
gf_jitter(Watching_TV_Hours~ClassGrade, data= CensusSchool2)
lm(Watching_TV_Hours~ClassGrade, data= CensusSchool2)-> Census.M1
supernova(Census.M1)
Census.Model <- lm(Watching_TV_Hours ~ ClassGrade, data = CensusSchool2)
Census.Model
lm(Watching_TV_Hours ~ shuffle(ClassGrade), data = CensusSchool2)
do(1000)*lm(Watching_TV_Hours ~ shuffle(ClassGrade), data = CensusSchool2) ->Census.Model
do(1000)*lm(Watching_TV_Hours ~ shuffle(ClassGrade), data = CensusSchool2)
Census.Model2<- b1(Watching_TV_Hours ~ ClassGrade, data = CensusSchool2)
gf_histogram(~Watching_TV_Hours, data = Census.Model, fill = "blue") %>%
gf_vline(xintercept = 1) %>%
gf_labs(title = "Distribution of Tv hours/classgrade")
confint(CensusSchool2)
Warning message:
“geom_vline(): Ignoring `mapping` because `xintercept` was provided.”
ERROR while rich displaying an object: Error in FUN(X[[i]], ...): object 'Watching_TV_Hours' not found
Traceback:
1. FUN(X[[i]], ...)
2. tryCatch(withCallingHandlers({
. if (!mime %in% names(repr::mime2repr))
. stop("No repr_* for mimetype ", mime, " in repr::mime2repr")
. rpr <- repr::mime2repr[[mime]](obj)
. if (is.null(rpr))
. return(NULL)
. prepare_content(is.raw(rpr), rpr)
. }, error = error_handler), error = outer_handler)
3. tryCatchList(expr, classes, parentenv, handlers)
4. tryCatchOne(expr, names, parentenv, handlers[[1L]])
5. doTryCatch(return(expr), name, parentenv, handler)
6. withCallingHandlers({
. if (!mime %in% names(repr::mime2repr))
. stop("No repr_* for mimetype ", mime, " in repr::mime2repr")
. rpr <- repr::mime2repr[[mime]](obj)
. if (is.null(rpr))
. return(NULL)
. prepare_content(is.raw(rpr), rpr)
. }, error = error_handler)
7. repr::mime2repr[[mime]](obj)
8. repr_text.default(obj)
9. paste(capture.output(print(obj)), collapse = "\n")
10. capture.output(print(obj))
11. evalVis(expr)
12. withVisible(eval(expr, pf))
13. eval(expr, pf)
14. eval(expr, pf)
15. print(obj)
16. print.gf_ggplot(obj)
17. NextMethod()
18. print.ggplot(obj)
19. ggplot_build(x)
20. ggplot_build.ggplot(x)
21. by_layer(function(l, d) l$compute_aesthetics(d, plot))
22. f(l = layers[[i]], d = data[[i]])
23. l$compute_aesthetics(d, plot)
24. f(..., self = self)
25. scales_add_defaults(plot$scales, data, aesthetics, plot$plot_env)
26. lapply(aesthetics[new_aesthetics], eval_tidy, data = data)
27. FUN(X[[i]], ...)