help(spline) and help(na.spline) do not help me understand why I am getting this error, and there is nothing online that seems to address this directly.
I have a matrix that I generated from these two commands:
RatioTable <- ddply(Key, c('Name', 'Position'), function(x) c(AvgRatio = mean(x$RatioMeanBid)))
RatioMatrix <- daply(RatioTable, .(Name, Position), function(x) x$AvgRatio)
> RatioMatrix
             Position
     Name     1    2    3    4    5
      a      0.4  0.3  0.2  0.2   NA
      b      0.6  0.7   NA   NA  0.5
      c       NA  0.7   NA   NA   NA
      d      0.5  0.4  0.3  0.3  0.2
      e       NA   NA   NA   NA   NA
> str(RatioMatrix)
 num [1:5, 1:5] 0.4 0.6 NA 0.5 NA ...
 - attr(*, "dimnames")=List of 2
  ..$ Name      : chr [1:8305] "a" "b" "c" "d" ...
  ..$ Position: chr [1:10] "1" "2" "3" "4" ...
If I then execute the following interpolation spline commands on RatioMatrix, it WORKS:
d0 <- as.Date("2000-01-01")
RatioMatrix2 <- exp(na.spline(zoo(t(log(RatioMatrix)), d0 + seq_len(ncol(RatioMatrix))), 
                                method = "natural", na.rm = FALSE))
However, if I make any changes or additions to RatioMatrix such as truncation or adjusting the values in column 1 (so that they are larger than those in column 2), the interpolation spline command throws out an error:
RatioMatrix <- daply(RatioTable, .(Name, Position), function(x) x$AvgRatio)
Pos1Greater <- data.frame(RatioMatrix[,1] >= RatioMatrix[,2])
Pos2Greater <- data.frame(RatioMatrix[,1] < RatioMatrix[,2])
Adj=(Pos1Greater*RatioMatrix[,1]) + (Pos2Greater*(RatioMatrix[,2]+0.05))
RatioMatrix[,1] = t(Adj)
d0 <- as.Date("2000-01-01")
RatioMatrix2 <- exp(na.spline(zoo(t(log(RatioMatrix)), d0 + seq_len(ncol(RatioMatrix))), 
                                method = "natural", na.rm = FALSE))
Error in splinefun(x[!na], y[!na], ...) : zero non-NA points
I tried debug(splinefun) as suggested, but still not seeing where the NA's come from. Any ideas? Thanks for looking into this.