Need help for friend's class assignment, neither of us know R very well so I came here for help

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.

There needs to be a comma after reaction$age in this command

plot (lmod$residuals ~ reaction$age
main = "Residual", xlab = "Age in Years", ylab = "Reaction Time")
```

Now it's just giving us this error

Error in eval(predvars, data, env) : object 'lmod' not found

abline(h=0)
plot (lmod$residuals ~ reaction$age,

  • main = "Residual", xlab = "Age in Years", ylab = "Reaction Time")
    Error in eval(predvars, data, env) : object 'lmod' not found

abline(h=0)

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.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

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