View source: R/get_centroid_weighted.R
get_centroid_weighted | R Documentation |
Returns the column weighted mean of the random points in each hypervolume. Useful for hypervolumes generated with hypervolume_n_occupancy()
or hypervolume_n_occupancy_test()
.
get_centroid_weighted(hv)
hv |
A |
The function get_centroid_weighted()
differs from get_centroid()
because it uses occupancy values to weight random points for evaluating centroids position.
Either a vector or a matrix of column of centroid values along each axis.
hypervolume_n_occupancy
, hypervolume_n_occupancy_test
## Not run:
data(penguins,package='palmerpenguins')
penguins_no_na = as.data.frame(na.omit(penguins))
penguins_no_na_split = split(penguins_no_na,
paste(penguins_no_na$species, penguins_no_na$sex, sep = "_"))
hv_list = lapply(penguins_no_na_split, function(x)
hypervolume_gaussian(x[, c("bill_length_mm","bill_depth_mm","flipper_length_mm")],
samples.per.point=100))
hv_list = hypervolume_join(hv_list)
hv_occupancy = hypervolume_n_occupancy(hv_list)
# unweighted centroids
get_centroid(hv_occupancy)
# weighted centroids
get_centroid_weighted(hv_occupancy)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.