[R] Interpolation
Adaikalavan Ramasamy
gisar at nus.edu.sg
Thu Feb 13 08:21:04 CET 2003
Here is another way of doing it:
x <- c(1990, 1994, 1995, 1997)
all.x <- seq(min(x), max(x))
complementary.x <- setdiff(all.x, x)
-----Original Message-----
From: Sundar Dorai-Raj [mailto:sundar.dorai-raj at pdf.com]
Sent: Wednesday, February 12, 2003 9:39 PM
To: Remigijus Lapinskas
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Interpolation
Remigijus Lapinskas wrote:
> Many thanks to all who replied to my e-mail. My problem was that I had
> not known about the approx function.
>
> By the way, if I have x <- c(1990,1994,1995,1997), is there an
> automated way to fill in the gaps, i.e., to get
> c(1991,1992,1993,1996)?
>
Try this:
R> x <- c(1990, 1994, 1995, 1997)
R> all.x <- seq(min(x), max(x))
R> missing.x <- all.x[!all.x %in% x]
R> missing.x
[1] 1991 1992 1993 1996
R>
Regards,
Sundar
______________________________________________
R-help at stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list