Alternatively, with approx() use xout to specify which interpolated
values you want returned:
approx(dat, xout=dat$V1[is.na(dat$V2)])
KJ
On 14/02/2013 11:43, Rui Barradas wrote:
Hello,
In what follows I've changed your df name to 'dat', to save some
keystrokes.
approxfun returns a function,
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 N
Readers,
According to the help '?approxfun', the function can be used to obtain
the interpolated values. The following test was tried:
> testinterpolation<-read.csv('test.csv',header=FALSE)
> testinterpolation
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
3 matches
Mail list logo