0

I am using the akima::bilinear function and it is generally working great. However, for some use cases, the interpolation grid is only 1 row but multiple columns. I know I could have an if statement and use use the approx() function instead but the code is cleaner without that and I don't understand why this doesn't work. For a reproducible example of what is failing:

x <- c(-1, -0.5, 0, 0.8, 1.5, 2.4, 4.3)
y <- 0
z <- matrix(c(1,2,3,4,5,6,7), nrow = 1)

akima::bilinear(x, 
                y, 
                z,
                x0 = c(1,2),
                y0 = c(1,2))

The error I get is:

Browse[2]> akima::bilinear(x,
                  y,
                  z,
                  x0 = c(1,2),
                  y0 = c(1,2))
Error in akima::bilinear(x, y, z, x0 = c(1, 2), y0 = c(1, 2)) :
  dim(z)[1] and length of x differs!
Mehrad Mahmoudian
  • 3,466
  • 32
  • 36
scopes
  • 1
  • 1

0 Answers0