Differs from polynom::as.character.polynomial() in that trailing zeros
are preserved.
poly2character(
x,
decreasing = getOption("ggpmisc.decreasing.poly.eq", FALSE),
digits = 3,
keep.zeros = TRUE
)A character string.
This is an edit of the code in package 'polynom' so that trailing zeros are retained during the conversion. It is not defined using a different name so as not to interfere with the original.
poly2character(1:3)
#> [1] "1.00 + 2.00*x + 3.00*x^2"
poly2character(1:3, decreasing = TRUE)
#> [1] "3.00*x^2 + 2.00*x + 1.00"