I have a polynomial 'p' of degree 4. How can I calculate the value of the polynomial 'p' forx = 1:10
x = 1:10
require(polynom) p <- polynomial(coef = c(1:5)) p 1 + 2x + 3x^2 + 4x^3 + 5x^4
try it
as.function(p)(1:10) # [1] 15 129 547 1593 3711 7465 13539 22737 35983 54321
whenever you want something to be something else in R, there might be a function as. .
as.
The polyom package suggests using the function predict :
predict
predict(p, newdata = 1:10) # [1] 15 129 547 1593 3711 7465 13539 22737 35983 54321