The correspondence python function; interp in R to get the same results

Hello all,
what is the correspondence to python function; “interp” in R to get the same results below

>> xp = [1, 2, 3]
>> fp = [3, 2, 0]
>> np.interp(2.5, xp, fp)
1.0
>> np.interp([0, 1, 1.5, 2.72, 3.14], xp, fp)
array([3.  , 3.  , 2.5 , 0.56, 0.  ])
>> UNDEF = -99.0
>> np.interp(3.14, xp, fp, right=UNDEF)
-99.0

and thanks in adavnce.

Hi Rani, this kind of question is better suited to the RStudio forums: https://community.rstudio.com/

2 Likes

I did :) thanks