View source: R/display_functions.R
get_r2 | R Documentation |
get_r2
is a is a wrap function that calls r2
from package performance
.
Calculates the R2 or pseudo-R2 value for different regression model objects, returning a character object for easy printing in tables of coefficients.
get_r2(model, ...)
model |
A statistical regression model. |
... |
Additional arguments passed to |
The main purpose of get_r2
is to allow easy printing of R2 value in tables of coefficients (see examples).
r2
.
require(dplyr, quietly = TRUE)
require(sjlabelled, quietly = TRUE)
data(birthwt, package = "MASS")
birthwt <- birthwt |>
mutate(
smoke = factor(smoke, labels = c("Non-smoker", "Smoker")),
race = factor(race, labels = c("White", "African American", "Other"))
) |>
var_labels(
bwt = "Birth weight (g)",
smoke = "Smoking status",
race = "Race"
)
model_norm <- lm(bwt ~ smoke + race, data = birthwt)
get_r2(model_norm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.