coefs2poly_eq: Format a polynomial as an equation

View source: R/utilities-eq-label.R

coefs2poly_eqR Documentation

Format a polynomial as an equation

Description

Uses a vector of coefficients from a model fit of a polynomial to build the fitted model equation with embedded coefficient estimates.

Usage

coefs2poly_eq(
  coefs,
  coef.digits = 3L,
  coef.keep.zeros = TRUE,
  decreasing = getOption("ggpmisc.decreasing.poly.eq", FALSE),
  eq.x.rhs = "x",
  lhs = "y~`=`~",
  output.type = "expression",
  decimal.mark = "."
)

Arguments

coefs

numeric Terms always sorted by increasing powers.

coef.digits

integer

coef.keep.zeros

logical This flag refers to trailing zeros.

decreasing

logical It specifies the order of the terms in the returned character string; in increasing (default) or decreasing powers.

eq.x.rhs

character

lhs

character

output.type

character One of "expression", "latex", "tex", "text", "tikz", "markdown".

decimal.mark

character

Value

A character string.

Note

Terms with zero-valued coefficients are dropped from the polynomial.

Examples

coefs2poly_eq(c(1, 2, 0, 4, 5, 2e-5))
coefs2poly_eq(c(1, 2, 0, 4, 5, 2e-5), output.type = "latex")
coefs2poly_eq(0:2)
coefs2poly_eq(0:2, decreasing = TRUE)
coefs2poly_eq(c(1, 2, 0, 4, 5), coef.keep.zeros = TRUE)
coefs2poly_eq(c(1, 2, 0, 4, 5), coef.keep.zeros = FALSE)


ggpmisc documentation built on June 28, 2024, 1:07 a.m.