0
s=sample(1:nrow(data), 0.80*nrow(data))

train <- data[s,]
test <- data[-s,]
test1 <- test[!colnames(test) %in% "Sale_Price"]
model1 <- lm(Sale_Price~., data = train)
pred1 <- predict(model1,test1)

Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : factor Condition2 has new levels PosA >

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
  • Welcome to SO! You maximise your chance of getting a useful answer if you provide a minimum reproducible example. [This post](https://stackoverflow.com/help/minimal-reproducible-example) may help. In partocular we need to see your input data in this case. – Limey Aug 10 '20 at 15:16
  • https://stackoverflow.com/questions/51552203/how-to-debug-factor-has-new-levels-error-for-linear-model-and-prediction – user20650 Aug 10 '20 at 16:45

0 Answers0