View source: R/regression_interactive.R
interactive_regression | R Documentation |
Interactive visualization function that lets you point-and-click to add data points, while it automatically plots and updates a regression line and associated statistics.
interactive_regression(points, ...) Click on the plotting area to add points and see a corresponding regression line (hitting ESC will stop the simulation).
points |
An optional |
... |
Further arguments passed to the |
A dataframe
containing the points coordinates. Additionally, the following parameters are provided on the plot area:
Raw intercept |
The y-coordinate at which the regression line crosses the y-axis. |
Raw slope |
The value of the slope parameter. |
Correlation |
The strength of the linear relationship. |
SSR |
The sum of squares regression. |
SSE |
The sum of squares error. |
SST |
The sum of squares total. |
R-squared |
The multiple coefficient of determination. |
plot_regr
# Selecting coordinates on the plot area, storing them in 'pts' pts <- interactive_regression() # Replotting the points stored earlier in 'pts', allowing the user to continue the interactive regression interactive_regression(pts) # Providing coordinates beforehand points <- data.frame(x = c(1, 4, 7), y = c(2, 5, 8)) # Replotting the coordinates and continuing the interactive regression interactive_regression(points)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.