Reputation: 503
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)
Upvotes: 5
Views: 9118
Reputation: 18759
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.
Upvotes: 6