Skip to content
Prev 317542 / 398503 Next

approxfun values

Hello,

In what follows I've changed your df name to 'dat', to save some keystrokes.
approxfun returns a function, so if you want just the interpolated 
values, apply that function to the x values where y is NA.



dat <- read.table(text = "
  V1 V2
1   10  2
2   20 NA
3   30  5
4   40  7
5   50 NA
6   60 NA
7   70  2
8   80  6
9   90  9
10 100 NA
", header = TRUE)

f <- approxfun(dat)
x <- dat$V1[is.na(dat$V2)]
y <- f(x)
y


Hope this helps,

Rui Barradas

Em 14-02-2013 08:43, e-letter escreveu: