Multiple linear regression error

I am a little rusty but am trying to create a linear regression model to forecast sales but keep running into some road blocks so thought I'd come here for help instead of spinning my wheels.

I have a lot of independent variables in my file, but when I run model below I get error message saying unexpected '=' in model1 and I am not sure how to fix it?

model1 <-
lm(Finaldf$Actual Sales ~ data = Finaldf[,c(4,5,7:63)])

If you want to fit Actual Sales against all the other variables, try

model1 <- lm(`Actual Sales` ~ .,  data = Finaldf[,c(4,5,7:63)])

Thanks for your response. When I tried that I got the following error message below. Any thoughts?

Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels

It seems at least one of your columns has only one value. Exclude those columns from the data set.

Thank you, that worked!

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.