Learn R Programming

insight (version 0.19.11)

standardize_names: Standardize column names

Description

Standardize column names from data frames, in particular objects returned from parameters::model_parameters(), so column names are consistent and the same for any model object.

Usage

standardize_names(data, ...)

# S3 method for parameters_model standardize_names( data, style = c("easystats", "broom"), ignore_estimate = FALSE, ... )

Value

A data frame, with standardized column names.

Arguments

data

A data frame. In particular, objects from easystats package functions like parameters::model_parameters() or effectsize::effectsize() are accepted, but also data frames returned by broom::tidy() are valid objects.

...

Currently not used.

style

Standardization can either be based on the naming conventions from the easystats-project, or on broom's naming scheme.

ignore_estimate

Logical, if TRUE, column names like "mean" or "median" will not be converted to "Coefficient" resp. "estimate".

Details

This method is in particular useful for package developers or users who use, e.g., parameters::model_parameters() in their own code or functions to retrieve model parameters for further processing. As model_parameters() returns a data frame with varying column names (depending on the input), accessing the required information is probably not quite straightforward. In such cases, standardize_names() can be used to get consistent, i.e. always the same column names, no matter what kind of model was used in model_parameters().

For style = "broom", column names are renamed to match broom's naming scheme, i.e. Parameter is renamed to term, Coefficient becomes estimate and so on.

For style = "easystats", when data is an object from broom::tidy(), column names are converted from "broom"-style into "easystats"-style.

Examples

Run this code
if (FALSE) { # require("parameters")
model <- lm(mpg ~ wt + cyl, data = mtcars)
mp <- model_parameters(model)

as.data.frame(mp)
standardize_names(mp)
standardize_names(mp, style = "broom")
}

Run the code above in your browser using DataLab