R插值

use*_*113 -2 interpolation r

我必须成对值:

A    B
211  2
19   1
Run Code Online (Sandbox Code Playgroud)

如何为值A = 132插值B?

flo*_*del 7

使用approx(线性插值):

grid <- data.frame(A = c(211, 19), B = c(2, 1))
grid
#     A B
# 1 211 2
# 2  19 1

approx(x = grid$A, y = grid$B, xout = 132)
# $x
# [1] 132
# 
# $y
# [1] 1.588542
Run Code Online (Sandbox Code Playgroud)