get_centroid_weighted {hypervolume}R Documentation

Get weighted centroid of hypervolume or hypervolume list

Description

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().

Usage

get_centroid_weighted(hv)

Arguments

hv

A Hypervolume or HypervolumeList object.

Details

The function get_centroid_weighted() differs from get_centroid() because it uses occupancy values to weight random points for evaluating centroids position.

Value

Either a vector or a matrix of column of centroid values along each axis.

See Also

hypervolume_n_occupancy, hypervolume_n_occupancy_test

Examples

## 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)

[Package hypervolume version 3.1.4 Index]