Description Usage Arguments Details See Also Examples

View source: R/display_functions.R

`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.

1 |

`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`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
require(dplyr, quietly = TRUE)
require(sjlabelled, quietly = TRUE)
require(huxtable, 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)
model_norm %>%
glm_coef(labels = model_labels(model_norm)) %>%
as_hux() %>% set_align(everywhere, 2:3, "right") %>%
theme_pubh(1) %>%
add_footnote(get_r2(model_norm), font_size = 9)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.