extract_group_metrics {nichetools} | R Documentation |
Extract group metrics within each community from a matrix object
that is produced by groupMetricsML()
function from
SIBER. These metrics
are the following the convex hull total area (TA), Standard Ellipse Area (SEA), and the
corresponding small sample size corrected version SEAc based on the maximum likelihood
estimates of the means and covariance matrices of each group.
extract_group_metrics(data = NULL, community_df = NULL, data_format = NULL)
data |
a |
community_df |
a four column data frame. One of the columns has to be named
|
data_format |
a |
A tibble
containing four rows when data_format
is set to its
default which is long
. These four rows are the following, community
,
the_name_of_the_communities
, metric
and post_est
.
library(SIBER)
# ---- create community names data frame ----
# uncomment to use
# str(demo.siber.data.2)
demo.siber.data.2$group_name <- as.factor(demo.siber.data.2$group)
demo.siber.data.2$group <- as.numeric(demo.siber.data.2$group_name) |>
as.character()
demo.siber.data.2$community_name <- as.factor(demo.siber.data.2$community)
demo.siber.data.2$community <- as.numeric(demo.siber.data.2$community_name) |>
as.character()
cg_name <- demo.siber.data.2 |>
dplyr::distinct(community, group, community_name, group_name)
# ---- create comparsions ----
demo.siber.data.2 <- demo.siber.data.2[,1:4]
siber_example <- createSiberObject(demo.siber.data.2)
# extract group metrics
group_ml <- groupMetricsML(siber_example)
group_convert <- extract_group_metrics(data = group_ml,
community_df = cg_name)