I am trying to make an interpolation for all the rows in a dataframe. I am using apply(data_final,2,na.approx)
. This make the interpolation for the values but some are out of range.
If I use na.approx(data_final[8,])
instead, I get a different value at that row compared to the row using apply
.
Also, if I do na.approx(data_final)
I get the same result as apply(data_final,2,na.approx)
. It doesn't make any sense since supposedly apply is applying na.approx
function to every row in the data frame.
apply(data_final,2,na.approx) [8,] 0.63 0.49 2.40 2.65 3.65 5.80 0.96 1.85 1.43 1.25 1.21 1.20 0.91 1.00 0.96 0.80 1.42 1.82 1.910
na.approx(data_final[8,]) [1] 0.630 0.490 0.584 0.678 0.772 0.866 0.960 1.850 1.430 1.250 1.210 1.200 0.910 1.000 0.960 0.800 1.420 1.820 1.910 1.780 1.620 [22] 1.650 1.380 1.370