0

After creating a plot of plant height vs shoot diameter, I want to add a line resulting from a linear regression. However, I keep getting a strange error with abline().

plot(log(conyza$diameter_cm), log(conyza$height_cm), 
main = "Shoot diameter and Plant height", xlab = "Shoot diameter", ylab = "Plant height")
Regression1 <- lm(conyza$LOGheight ~ conyza$LOGdiameter) 
abline(coef = Regression1$coefficients)

I then get the error: Error in abline(coef = Regression1wo$coefficients) : ... must contain names or character strings

One suggestion was that the error is because Regression1$coefficients is a table, but if I try the following code, I get the exact same error.

abline(4, 0.5)

The same goes for:

abline(a = 4, b = 0.5)

I had this issue once before and was able to fix it by just restarting R. This time, however, restarting R doesn't fix the problem. Does anyone have another suggestion for what's happening and how I can avoid this error?

Kat
  • 1
  • I tried updating my R Studio and R as well, to no avail. Please help me :') – Kat Sep 14 '21 at 15:34
  • Tried restarting R session for 20th time, this time it worked... mysterious :( – Kat Sep 14 '21 at 15:37
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Sep 14 '21 at 23:06

0 Answers0