My friend must make a residual plot for the relation between age and reaction time for one of his statistics class. He copied and pasted the code provided in the assignment. Everything works up until he reaches this code:
lmod <- lm(time ~ age, data = reaction)
plot (lmod$residuals ~ reaction$age
main = "Residual", xlab = "Age in Years", ylab = "Reaction Time")
abline(h=0)
qqnorm(lmod$residuals,
pch = 15, col = "blue",
main = "Normal Probability Plot of Residuals")
qqline(lm$residuals)
options(show.signif.stars = FALSE)
summary(lmod)
Which gives him this error:
Error: unexpected symbol in:
"plot (lmod$residuals ~ reaction$age
main"
Neither of us have much experience in coding or R studio. Any help we can get would be greatly appreciated.
The error message is self explanatory, there is no object called lmod so something must have went wrong on the previous step where you create that object.