if(requireNamespace("fda", quietly = TRUE)) {
# Consider ordering of the girls in the Berkeley Growth Study data
# available from the R package fda, see ?growth, according to their
# annual heights or/and changes within years.
# First create sets of curves (vectors), for raw heights and
# for the differences within the years
years <- paste(1:18)
curves <- fda::growth[['hgtf']][years,]
cset1 <- curve_set(r = as.numeric(years),
obs = curves)
cset2 <- curve_set(r = as.numeric(years[-1]),
obs = curves[-1,] - curves[-nrow(curves),])
# Order the girls from most extreme one to the least extreme one, below using the 'area' measure
# a) according to their heights
forder(cset1, measure = 'area')
# Print the 10 most extreme girl indices
order(forder(cset1, measure = 'area'))[1:10]
# b) according to the changes (print indices)
order(forder(cset2, measure = 'area'))[1:10]
# c) simultaneously with respect to heights and changes (print indices)
csets <- list(Height = cset1, Change = cset2)
order(forder(csets, measure = 'area'))[1:10]
}
Run the code above in your browser using DataLab