[R] Why missing values are not allowed in 'poly'?

Liviu Andronic landronimirc at gmail.com
Wed Mar 23 20:59:04 CET 2016

Dear all,
I'm a bit surprised by this behavior in poly:

x <- c(NA, 1:10)
poly(x, degree = 2, raw=TRUE)
## Error in poly(x, degree = 2, raw = TRUE) :
##   missing values are not allowed in 'poly'
## [1] NA 1 4 9 16 25 36 49 64 81 100

As you can see, poly() will fail if the vector contains NAs, whereas
it is perfectly possible to obtain the square of the vector manually.

Is there a reason for this limitation in poly?


Do you think you know what math is?
Or what it means to be intelligent?
Think again:

More information about the R-help mailing list