Next time please provide sample data in a form we can easily read in (look at 
?dput for example)

If i understand this right:

yourData<-read.table(header=T,text="
date                    days  rate
1996_01_02      15    5.74590
1996_01_02      50    5.67332
1996_01_02      78    5.60888
1996_01_02     169    5.47376
1996_01_02     260    5.35267
1996_01_02     351    5.27619

1996_01_03      14    5.74740
1996_01_03      49    5.67226
1996_01_03      77    5.60371
1996_01_03     168    5.47058
1996_01_03     259    5.34662
1996_01_03     350    5.26630
")

results<-sapply(unique(yourData$date),function(thisDate){
                        subSet <- yourData[yourData$date==thisDate,]
                        appr<-approx(subSet$days,subSet$rate,xout=seq(0,360, 
by=30))
                        rates<-appr$y
                        names(rates)<-appr$x
                        rates
                })
colnames(results)<-unique(yourData$date)

This gives 13 results per date though, and it can't interpolate the first and 
last value. If you need those values that are not in-between, try spline 
instead of approx (you never specified how you wanted to interpolate).

On 17.01.2013, at 15:50, beanbandit wrote:

> hi guys
> 
> I need to interpolate values for the zero coupon yield curve. Following data
> is given
> 
> 
> 
>    date            days      rate
> 
> 1996 01 02      15    5.74590
> 1996 01 02      50    5.67332
> 1996 01 02      78    5.60888
> 1996 01 02     169    5.47376
> 1996 01 02     260    5.35267
> 1996 01 02     351    5.27619
> 
> 1996 01 03      14    5.74740
> 1996 01 03      49    5.67226
> 1996 01 03      77    5.60371
> 1996 01 03     168    5.47058
> 1996 01 03     259    5.34662
> 1996 01 03     350    5.26630
> 
> For every day i have to interpolate 10 values, for example for maturities of
> 30,60 or 90 days. I have interpolate data for a one year period, 10
> interpolation values a day, so that equals 3600 values. 
> 
> what's the easiest way to implement this in R?
> 
> please hlep!
> 
> 
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Help-with-interpolation-tp4655843.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to