binary_to_table {AnthropMMD}R Documentation

Converts a data frame of binary (i.e., presence/absence) trait information into a table of sample sizes and frequencies.

Description

This function allows to get a summary of sample sizes and frequencies for each trait in each group. It is also mandatory to apply this function before using the mmd function, since the latter only accepts table of frequencies, and cannot work with raw binary data.

Usage

binary_to_table(data, relative = FALSE)

Arguments

data

A binary (0/1 for presence/absence of traits) data frame with n rows (one per individual) and p+1 columns (one for each of the p traits, plus one column provided as a group indicator).

relative

Boolean. Indicates if the last rows of the table must contain frequencies (i.e., number of individuals having a given trait) or relative frequencies (i.e., proportions).

Value

A matrix with 2*K rows (K being the number of groups in the dataset) and p columns (one per trait). The first K rows are the sample sizes, the last K rows are trait frequencies.

Author(s)

Frédéric Santos, frederic.santos@u-bordeaux.fr

References

Santos, F. (2018) AnthropMMD: an R package with a graphical user interface for the mean measure of divergence. American Journal of Physical Anthropology, 165(1), 200–205. doi: 10.1002/ajpa.23336

See Also

start_mmd

Examples

## Load and visualize a binary dataset:
data(toyMMD)
head(toyMMD)

## Convert this dataframe into a table of sample sizes and relative frequencies:
binary_to_table(toyMMD, relative = TRUE)

[Package AnthropMMD version 4.0.3 Index]