Prestige <- read.table('http://math.uttyler.edu/nathan/classes/statistics/data/prestige.data',header=TRUE) Prestige[1:10,] boxplot(Prestige$income) hist(Prestige$income) Prestige$income[7:10] Prestige$income[Prestige$income > 10000] Prestige$income[Prestige$type == "prof"] # incomes for professionals Prestige$income[Prestige$type == "wc"] # incomes for white collars boxplot(Prestige$income[Prestige$type=="prof"],Prestige$income[Prestige$type=="wc"]) ###### a helpful shortcut to typing: attach(Prestige) # the previous boxplot boxplot(income[type=="prof"],income[type=="wc"]) ###### when you're done, don't forget to # detach(Prestige) t.test(income[type=="prof"],income[type=="wc"]) # Welch Two Sample t-test # #data: income[type == "prof"] and income[type == "wc"] #t = 5.2202, df = 39.673, p-value = 5.977e-06 #alternative hypothesis: true difference in means is not equal to 0 #95 percent confidence interval: # 3374.411 7639.884 #sample estimates: #mean of x mean of y #10559.452 5052.304 # #### 95% ci for difference between prof and wc incomes is ##### 3374 to 7639 t.test(income[type=='wc'],income[type=='bc'])