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
Examples
coefs2poly_eq(c(1, 2, 0, 4, 5, 2e-5))
#> [1] "y~`=`~1.00 + 2.00*x + 4.00*x^3 + 5.00*x^4 + 2.00%*% 10^{-05}*x^5"
coefs2poly_eq(c(1, 2, 0, 4, 5, 2e-5), output.type = "latex")
#> [1] "y~`=`~1.00 + 2.00x + 4.00x^3 + 5.00x^4 + 2.00\\times{} 10^{-05}x^5"
coefs2poly_eq(0:2)
#> [1] "y~`=`~1.00*x + 2.00*x^2"
coefs2poly_eq(0:2, decreasing = TRUE)
#> [1] "y~`=`~2.00*x^2 + 1.00*x"
coefs2poly_eq(c(1, 2, 0, 4, 5), coef.keep.zeros = TRUE)
#> [1] "y~`=`~1.00 + 2.00*x + 4.00*x^3 + 5.00*x^4"
coefs2poly_eq(c(1, 2, 0, 4, 5), coef.keep.zeros = FALSE)
#> [1] "y~`=`~1 + 2*x + 4*x^3 + 5*x^4"