I'm trying to use interactive plots generated with R to show my students how changing the rise and run affect a line's slope. I've basically done this with the following code, but I'd like to find a way to highlight the points (x_1, y_1), (x_2, y_2) as well:
manipulate(
plot(x<-seq(from = -3,
to = 3,
by = .02),
y=(y_2-y_1/(x_2-x_1))*x,
type = "l",
ylim = c(-5,5),
panel.first = grid()),
y_2=slider(min = -3, 3, initial = 1, step = .5),
y_1=slider(min = -3, 3, initial = 0, step = .5),
x_2=slider(min = -3, 3, initial = 1, step = .5),
x_1=slider(min = -3, 3, initial = 0, step = .5)
)
I appreciate any help that you can offer