split()
divides the hyperSpec
object into a list of
hyperSpec
objects according to the groups given by f
.
# S4 method for hyperSpec
split(x, f, drop = TRUE)
the hyperSpec
object
a factor giving the grouping (or a variable that can be converted
into a factor by as.factor
)
if TRUE
, levels off
that do not occur are dropped.
A list of hyperSpec
objects.
The hyperSpec
objects in the list may be bound together again by
bind("r", list_of_hyperSpec_objects)
.
dist <- dist_pearson(faux_cell[[]])
dend <- hclust(dist, method = "ward")
#> The "ward" method has been renamed to "ward.D"; note new "ward.D2"
z <- cutree(dend, h = 0.15)
region <- split(faux_cell, z)
length(region)
#> [1] 54
# difference in cluster mean spectra
plot(apply(region[[2]], 2, mean) - apply(region[[1]], 2, mean))