load('gss.Rdata') # realy hard work here to supress annoying messages suppressWarnings(library(ggplot2)) suppressPackageStartupMessages(suppressWarnings(library(dplyr))) suppressPackageStartupMessages(suppressWarnings(library(gridExtra))) library(statsr) gss_job = gss %>% select(jobinc, jobsec, jobpromo, jobmeans, class) summary(gss_job) gss_job = na.omit(gss_job) gr_inc = ggplot(gss_job, aes(jobinc, fill=jobinc)) + geom_bar() + labs(title = "Income") + guides(fill=FALSE) gr_sec = ggplot(gss_job, aes(jobsec, fill=jobsec)) + geom_bar() + labs(title = "Security") + guides(fill=FALSE) gr_promo = ggplot(gss_job, aes(jobpromo, fill=jobpromo)) + geom_bar() + labs(title = "Promotion") + guides(fill=FALSE) gr_means = ggplot(gss_job, aes(jobmeans, fill=jobmeans)) + geom_bar() + labs(title = "Meaning") + guides(fill=FALSE) grid.arrange(gr_inc, gr_sec, gr_promo, gr_means, ncol=2, nrow =2) gss_job %>% group_by(class) %>% summarise(income = median(as.numeric(jobinc)), security = median(as.numeric(jobsec)), promotion = median(as.numeric(jobpromo)), meaning = median(as.numeric(jobmeans)), count = n()) gss_job %>% group_by(class) %>% summarise(income = mean(as.numeric(jobinc)), security = mean(as.numeric(jobsec)), promotion = mean(as.numeric(jobpromo)), meaning = mean(as.numeric(jobmeans)), count = n()) # setup printing options # options(repr.plot.width = 4) options(repr.plot.height = 4) inference(jobsec, class, data=gss_job, type = "ht", method = "theoretical", alternative="greater", null=0, statistic = "proportion") inference(jobmeans, class, data=gss_job, type = "ht", method = "theoretical", alternative="greater", null=0, statistic = "proportion") chisq.test(gss_job$class, gss_job$jobsec)