as.data.frame.estimate_contrasts: Converting modelbased-objects into raw data frames

View source: R/as.data.frame.R

as.data.frame.estimate_contrastsR Documentation

Converting modelbased-objects into raw data frames

Description

as.data.frame() method for modelbased objects. Can be used to return a "raw" data frame without attributes and with standardized column names. By default, the original column names are preserved, to avoid unexpected changes, but this can be changed with the preserve_names argument.

Usage

## S3 method for class 'estimate_contrasts'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  ...,
  stringsAsFactors = FALSE,
  use_responsename = FALSE,
  preserve_names = TRUE
)

Arguments

x

An object returned by the different ⁠estimate_*()⁠ functions.

row.names

NULL or a character vector giving the row names for the data frame. Missing values are not allowed.

optional

logical. If TRUE, setting row names and converting column names (to syntactic names: see make.names) is optional. Note that all of R's base package as.data.frame() methods use optional only for column names treatment, basically with the meaning of data.frame(*, check.names = !optional). See also the make.names argument of the matrix method.

...

Arguments passed to the data.frame method of as.data.frame().

stringsAsFactors

logical: should the character vector be converted to a factor?

use_responsename

Logical, if TRUE, the response variable name is used as column name for the estimate column (if available). If FALSE (default), the column is named "Coefficient".

preserve_names

Logical, if TRUE (default), the original column names are preserved. If FALSE, the estimate column is renamed to either the response name (if use_responsename = TRUE) or to "Coefficient".

Value

A data frame.

Examples


model <- lm(Petal.Length ~ Species, data = iris)
out <- estimate_means(model, "Species")

# default
print(out)

as.data.frame(out)

as.data.frame(out, preserve_names = FALSE)

as.data.frame(out, preserve_names = FALSE, use_responsename = TRUE)


modelbased documentation built on Dec. 8, 2025, 5:13 p.m.