[R] Interpolation
Remigijus Lapinskas
remigijus.lapinskas at maf.vu.lt
Wed Feb 12 14:09:03 CET 2003
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)?
Cheers,
Remigijus
Wednesday, February 12, 2003, 12:09:33 PM, you wrote:
PDB> Remigijus Lapinskas <remigijus.lapinskas at maf.vu.lt> writes:
>> Dear all,
>>
>> I have two vectors and connect the points by line segments:
>>
>> x <- c(1990,1994,1995,1997)
>> y <- c(30,40,80,20)
>> plot(x,y,type="l")
>>
>> I want to get the values of y's on these lines at missing x's,
>> i.e., at 1991,1992,1993,and 1996. Is there a simple way to do this?
PDB> approx(x,y,c(1991,1992,1993,1996))
PDB> plot(x,y,type="l")
PDB> points(approx(x,y,c(1991,1992,1993,1996)),pch="*",col="red",cex=5)
PDB> --
PDB> O__ ---- Peter Dalgaard Blegdamsvej 3
PDB> c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
PDB> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
PDB> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list