# Create functional data
t <- seq(0, 1, length.out = 100)
X <- matrix(0, 20, 100)
for (i in 1:20) X[i, ] <- sin(2*pi*t) + rnorm(100, sd = 0.1)
fd <- fdata(X, argvals = t)
# Extract 5 local average features
features <- localavg.fdata(fd, n.intervals = 5)
dim(features) # 20 x 5
# Use custom intervals
intervals <- cbind(c(0, 0.25, 0.5), c(0.25, 0.5, 1))
features2 <- localavg.fdata(fd, intervals = intervals)
Run the code above in your browser using DataLab