Description Usage Arguments Value Author(s) See Also Examples
Round the coefficients of an mpoly object.
1 2 | ## S3 method for class 'mpoly'
round(x, digits = 3)
|
x |
an mpoly object |
digits |
number of digits to round to |
the rounded mpoly object
David Kahle david@kahle.io
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | p <- mp("x + 3.14159265")^4
p
round(p)
round(p, 0)
## Not run:
library(plyr)
library(ggplot2)
library(stringr)
n <- 101
s <- seq(-5, 5, length.out = n)
# one dimensional case
df <- data.frame(x = s)
df <- mutate(df, y = -x^2 + 2*x - 3 + rnorm(n, 0, 2))
qplot(x, y, data = df)
mod <- lm(y ~ x + I(x^2), data = df)
p <- as.mpoly(mod)
qplot(x, y, data = df) +
stat_function(fun = as.function(p), colour = 'red')
p
round(p, 1)
qplot(x, y, data = df) +
stat_function(fun = as.function(p), colour = 'red') +
stat_function(fun = as.function(round(p,1)), colour = 'blue')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.