I am beginner to Scatter Plot. I have recently joined new project and they gave task to plot the simple best fit line to a scatterplot.
If I try to execute my below code with my data I always face the following error message:
plot(log(datatest$MEAN_intact_for),log(datatest$ERmammal_0_1), col= "blue")
title(main="Scatter plot with best-fit line", font.main= 4)
abline(lm(log(datatest$ERmammal_0_1)~log(datatest$MEAN_intact_for)), col= "red")
Please find below the error message which I receive.
“Error in formula.default(object, env = baseenv()) : invalid formula”.
I have already tried to do research on the above error but I am unable to fix it as I am very new to R So I am looking for the expert advise on above error so that I can fix it in less time.
Please Note : If I just plot my graph it works as expected but the problem comes up if I try to add a abline command to have a best fit line.