Skip to contents

Extracts a coefficient from an object and returns it as a text string.

Usage

text_coef(x, ...)

# S3 method for default
text_coef(
  x,
  param = NULL,
  digits = getOption("out2text_coef_digits", 3),
  format = getOption("out2text_coef_format", "f"),
  ...
)

# S3 method for lm
text_coef(
  x,
  param = NULL,
  digits = getOption("out2text_coef_digits", 3),
  format = getOption("out2text_coef_format", "f"),
  ...
)

# S3 method for glm
text_coef(
  x,
  param = NULL,
  digits = getOption("out2text_coef_digits", 3),
  format = getOption("out2text_coef_format", "f"),
  ...
)

# S3 method for lavaan
text_coef(
  x,
  param = NULL,
  digits = getOption("out2text_coef_digits", 3),
  format = getOption("out2text_coef_format", "f"),
  standardized = FALSE,
  group = 1L,
  ...
)

Arguments

x

A supported object with coefficients in the results.

...

Optional arguments. Ignored for now.

param

The name of the term or parameter for which the coefficients will be returned.

digits

The number of decimal places to keep. To be passed to formatC().

format

The format string used in formatC(). Default is "f".

standardized

Logical. Whether the estimate in the standardized solution is to be returned. Default is FALSE.

group

For an lavaan-class object, the group from which the estimate is to be returned. Default is 1.

Value

A one-element character vector.

Details

Details (Include subjects for verbs.) (Use 3rd person forms for verbs.)

Examples


set.seed(894252)
n <- 10
x <- rnorm(n)
y <- .6 * x + rnorm(n, 0, .8)
out <- lm(y ~ x)
text_coef(out, "x")
#> [1] "0.433"