Learn R Programming

dotwhisker (version 0.2.0.5)

relabel_predictors: Relabel the Predictors in a Tidy Data Frame of Regression Results

Description

relabel_predictors is a convenience function for relabeling the predictors in a tidy data.frame to be passed to dwplot

Usage

relabel_predictors(df, replace = NULL)

Arguments

df
A tidy data.frame to be passed to dwplot
replace
A named character vector, with new values as values, and old values as names

Value

The function returns a tidy data.frame.

See Also

relabel_y_axis to relabel the predictors on the y-axis of a dot-whisker plot after using dwplot

Examples

Run this code
library(broom)
library(dplyr)

data(mtcars)
m1 <- lm(mpg ~ wt + cyl + disp, data = mtcars)
m1_df <- broom::tidy(m1) %>%
         relabel_predictors(c("(Intercept)" = "Intercept",
                              wt = "Weight",
                              cyl = "Cylinder",
                              disp = "Displacement"))
dwplot(m1_df)

Run the code above in your browser using DataLab