plot_3d_regression: Interactive 3D scatterplot with a fitted regression plane
Description
Build an interactive 3D scatterplot of an outcome against two numeric
predictors, overlaid with the fitted plane from lm(formula, data).
Returns a plotly htmlwidget that you can render in
an R Markdown / Quarto document or in the RStudio Viewer.
a data frame containing the three variables in formula.
formula
a formula of the form z ~ x + y: a single outcome on
the left-hand side and exactly two predictor variables on the
right-hand side. In-formula transformations (e.g. log(z) ~ x + y)
are not supported in this version — apply transformations to data
beforehand.
n
grid resolution per axis used to draw the regression plane.
Default 25.
Details
Requires the suggested package plotly. Install it with
install.packages("plotly") if you see an error about it being missing.