beans <- read.table("/home/units/r.data/broadbeans.dat", header=T) summary(beans) attributes(beans) attach(beans) attributes(Type) Concentration[Type=="Cut.shoot"] t.test( x=Concentration[Type=="Cut.shoot"], y=Concentration[Type=="Rooted.plant"] ) t.test( Concentration ~ Type ) bartlett.test( Concentration ~ Type ) t.test( Concentration ~ Type, var.equal=TRUE) t.test( Concentration ~ Type, var.equal=TRUE, alternative="greater") beans.test <- t.test( Concentration ~ Type, var.equal=TRUE, alternative="greater") names(beans.test) plot(beans) plot( Concentration ~ Type ) # Deal with potential outlier sort( Concentration[Type=="Cut.shoot"] ) detach(beans) beans <- beans[-4,] # A negative index *removes* the element attach(beans) plot( Concentration ~ Type ) t.test( Concentration ~ Type ) ks.test( x=Concentration[Type=="Cut.shoot"], y=Concentration[Type=="Rooted.plant"] ) detach(beans) ### Try another barley <- read.table("/home/units/r.data/split-R.dat", header=T) summary(barley) attach(barley) b.m1 <- lm( Yield ~ Block + Variety + Manure ) # Wrong! b.m1 <- lm( Yield ~ factor(Block) + factor(Variety) + factor(Manure) ) b.m1 detach(barley) barley$Block <- factor(barley$Block) barley$Variety <- factor(barley$Variety) attach(barley) b.m1 <- lm( Yield ~ factor(Block) + factor(Variety) + factor(Manure) ) b.m1 detach(barley)