HelloThere2354235
HelloThere2354235

Reputation: 1

R. T test for two groups that are part of different categories in the same data set?

I have a final lab and am trying to run a T-test to see if there is a significant difference between salary if you major in a STEM major vs a Humanity major vs a Social Science major. I have each major labeled as either SS, S, or H in one column. Is there a way I could compare each group easily? Thanks

Upvotes: 0

Views: 37

Answers (1)

You probably want to use the pairwise t-test functionality from here Pairwise T Test. I personally like to use the Bonferroni correction since it is conservative (it simply divides the p-thresholds by number of comparisons).

You also probably want to graph your output by using something like

dat_grouped <- dat %>% group_by(Major) %>% summarise(Mean_Salary = mean(Salary), SD_Salary = sd(Salary), N= n())
    ggplot(data = dat_grouped, aes(x=Major, y = Mean_Salary )) + 
    geom_col() + geom_errorbar(aes(ymin =Mean_Salary -1.96*SD_Salary , ymax = Mean_Salary +1.96*SD_Salary), width = 0.25)

Upvotes: 1

Related Questions