https://github.com/cran/fda
Tip revision: 4a63ac058ab1bcb69733d1882ec4eabb1fae1f4e authored by J. O. Ramsay on 03 November 2009, 00:00:00 UTC
version 2.3.1
version 2.3.1
Tip revision: 4a63ac0
subscript.R
"[.fd" <- function(fdobj, i=TRUE, j=TRUE, drop=TRUE) {
# select subsets of curves in a functional data object
coef <- as.array(fdobj$coefs)
fdnames <- fdobj$fdnames
coefdim <- dim(coef)
ndim <- length(coefdim)
if(ndim == 2) {
if (coefdim[2] == 1) {
coefselect <- coef
} else {
coefselect <- coef[, i, drop=FALSE]
}
if (length(fdnames[[2]])>1) {
fdnames[[2]] = fdnames[[2]][i]
}
} else {
if (coefdim[2] == 1) {
coefselect <- coef
} else {
coefselect <- coef[, i, j,drop=drop]
}
if(length(fdnames[[2]])>1){
fdnames[[2]] = fdnames[[2]][i]
}
if(length(fdnames[[3]])>1){
fdnames[[3]] = fdnames[[3]][j]
}
}
fd(coefselect, fdobj$basis, fdnames)
}