data <- matrix(scan(),ncol=3,byrow=TRUE) 1 1 106 1 1 108 1 2 93 1 2 101 1 2 98 1 3 56 2 1 107 2 1 110 2 1 116 2 2 63 2 2 60 2 3 40 2 3 41 2 3 44 data UnbalConcrete <- data.frame(data) colnames(UnbalConcrete) <- c("aggregate","compaction","strength") UnbalConcrete$aggregate <- as.factor(UnbalConcrete$aggregate) UnbalConcrete$compaction <- as.factor(UnbalConcrete$compaction) rm(data) levels(UnbalConcrete$aggregate) <- c("Basalt","Silicious") levels(UnbalConcrete$compaction) <- c("Regular","Low","VeryLow") UnbalConcrete # the anova function applied to an lm object calculates Type I SS anova(lm(strength ~ aggregate + compaction + aggregate:compaction, data = UnbalConcrete)) # the car package contains a function 'Anova' that can calculate Type II or Type III SS # it calculates Type II SS by default library(car) # this produces the results using Type II SS Anova(lm(strength ~ aggregate + compaction + aggregate:compaction, data = UnbalConcrete),type="II") # the Type III SS produced by using the type="III" argument do not match SAS results