RE: [R] Interpolation

About this list Date view Thread view Subject view Author view Attachment view

From: Adaikalavan Ramasamy (gisar@nus.edu.sg)
Date: Thu 13 Feb 2003 - 18:19:51 EST


Message-id: <024D6AEFCB92CB47BA1085751D184BB801053F02@MBXSRV03.stf.nus.edu.sg>

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@pdf.com]
Sent: Wednesday, February 12, 2003 9:39 PM
To: Remigijus Lapinskas
Cc: r-help@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@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help

______________________________________________
R-help@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:21 EST