| Poly {iNZightRegression} | R Documentation |
A modified 'poly()' function that allows for missing values.
Poly(x, degree = 1, coefs = NULL, raw = FALSE, ...)
x |
variable to convert to matrix |
degree |
degree of polynomial |
coefs |
pass to poly() function |
raw |
pass to poly() function |
... |
more arguments for the poly() function |
Credit goes to whoever posted this online first (google search if you must find it!)
a matrix, with NAs in the missing rows
Tom Elliott
Poly(rnorm(100), degree = 2L) # handles missing values: iris.na <- iris iris.na$Sepal.Length[c(5, 10)] <- NA lm(Sepal.Width ~ Poly(Sepal.Length, 2L), data = iris.na) # stats::poly() produces an error in this case: # lm(Sepal.Width ~ poly(Sepal.Length, 2L), data = iris.na)