data <- scan(what = list(method="",batch=0,sample=0,y=0), multi.line=F) A 1 1 120 A 1 2 110 A 2 3 120 A 2 4 100 A 3 5 140 A 3 6 130 B 4 7 71 B 4 8 71 B 5 9 70 B 5 10 76 B 6 11 63 B 6 12 68 data pesticide <- data.frame(data) rm(data) pesticide$method <- as.factor(pesticide$method) pesticide$batch <- as.factor(pesticide$batch) pesticide$sample <- as.factor(pesticide$sample) aov(y~method+Error(method/batch/sample),data=pesticide)