https://github.com/cran/fda
Tip revision: 2fc4de4b372bbc86c6cea004c617ad4a41b06b81 authored by J. O. Ramsay on 03 May 2014, 00:00:00 UTC
version 2.4.3
version 2.4.3
Tip revision: 2fc4de4
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)
}