[R] Scriptable Integration

R. Michael Weylandt michael.weylandt at gmail.com
Sat Feb 11 03:11:45 CET 2012


I'm not quite sure what you mean, but perhaps this will help:

library(splines)
mydata <- structure(list(V1 = c(1328565067, 1328565067.05, 1328565067.1,
1328565067.15, 1328565067.2, 1328565067.25), V2 = c(0.0963890795246276,
0.227296347215609, 0.240972698811569, 0.221208948983498, 0.230898231782485,
0.203282153087549), V3 = c(0.0245045248243853, 0.0835679411703579,
0.0612613120609633, 0.058568910563872, 0.0511868450318788, 0.0557714205674231
)), .Names = c("V1", "V2", "V3"), row.names = c(NA, 6L), class = "data.frame")

spf <- splinefun(mydata$V2)
splInt <- function(low, up) integrate(spf, low, up)$value

splInt(0, 1)

splInt(0, 2)

Michael

On Fri, Feb 10, 2012 at 6:34 PM, Hasan Diwan <hasan.diwan at gmail.com> wrote:
> My data:
>> dput(mydata)
> structure(list(V1 = c(1328565067, 1328565067.05, 1328565067.1,
> 1328565067.15, 1328565067.2, 1328565067.25), V2 = c(0.0963890795246276,
> 0.227296347215609, 0.240972698811569, 0.221208948983498, 0.230898231782485,
> 0.203282153087549), V3 = c(0.0245045248243853, 0.0835679411703579,
> 0.0612613120609633, 0.058568910563872, 0.0511868450318788, 0.0557714205674231
> )), .Names = c("V1", "V2", "V3"), row.names = c(NA, 6L), class = "data.frame")
>
> I'd like to apply an arbitrary number of integrations of the
> splinefunc from mydata$V2 and mydata$V3. Therefore, it should return a
> function. Anyone have any idea as to a package that allows this? Many
> thanks! -- H
> --
> Sent from my mobile device
> Envoyait de mon portable
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list