Error in model.frame.default

Hi guys, I'm a college student and I'm doing manova in R. I'm having a problem while trying to get the residuals, the error is like this

Error in model.frame.default(formula = data2$y1 ~ Variety, drop.unused.levels = TRUE) :
variable lengths differ (found for 'Variety')

This is my codes

> f <- file.choose("question2_HW4.txt")

> data2 <- read.table (f, header = TRUE)

> attach(data2)

> data2=na.omit(data2)

> location <- as.factor(data2[,1])

> Variety <- as.factor(data2[.2])

> y <- as.matrix(data2[,3:5])

> y1resloca= lm(data2$y1~location)$residuals

> y2resloca= lm(data2$y2~location)$residuals

> y3resloca= lm(data2$y3~location)$residuals

> y1resvari= lm(data2$y1~Variety)$residuals

Any help would be much appreciated.

This is the topic and the dataset

. 2 ?
Typo i think.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.