I would like to draw a straight line on plot using the following linear equation.
y = 2.522x-1.331
I used the following code to get a scatterplot.
data=read.csv("C://book.csv")
plot(data$x,data$y)
You need to use function abline
:
abline(a=-1.331, b=2.522)
Argument a
is the intercept and argument b
the slope.
See ?abline
for more details.
Use abline
, e.g.
abline(-1.331, 2.522)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With