Learn R Programming

rdiversity (version 1.2.1)

metacommunity: Coerce to metacommunity

Description

Functions to check if an object is a metacommunity or coerce an object into a metacommunity.

Usage

metacommunity(partition, similarity, ...)

# S4 method for data.frame,missing metacommunity(partition)

# S4 method for numeric,missing metacommunity(partition)

# S4 method for matrix,missing metacommunity(partition)

# S4 method for data.frame,matrix metacommunity(partition, similarity)

# S4 method for numeric,matrix metacommunity(partition, similarity)

# S4 method for matrix,matrix metacommunity(partition, similarity)

# S4 method for missing,phylo metacommunity(partition, similarity, depth = 1)

# S4 method for numeric,phylo metacommunity(partition, similarity, depth = 1)

# S4 method for data.frame,phylo metacommunity(partition, similarity, depth = 1)

# S4 method for matrix,phylo metacommunity(partition, similarity, depth = 1)

is.metacommunity(x)

Arguments

partition

two-dimensional matrix of mode numeric with rows as types, columns as subcommunities, and elements containing the relative abundances of types in subcommunities. For phylogenetic diversity, see Details.

similarity

(optional) two-dimensional matrix of mode numeric, with rows as types, columns as types, and elements containing the pairwise similarity between types. For phylogenetic diversity, see Details.

...

(optional) additional arguments, especially:

depth

(optional; and for phylogenetic metacommunities only) how much evolutionary history should be retained, with 0 marking the most recent present-day species, and 1 (the default) marking the most recent common ancestor. Numbers greater than 1 extend the root of the tree.

x

any R object

Value

Returns an object of class metacommunity (see Fields).

Returns TRUE if its argument is a metacommunity, FALSE otherwise.

Fields

type_abundance

two-dimensional matrix of mode numeric with rows as types, columns as subcommunities, and elements containing relative abundances of types in subcommunities. In the phylogenetic case, this corresponds to the proportional abundance of historic species, which is calculated from the proportional abundance of present day species.

similarity

two-dimensional matrix of mode numeric with rows as types, columns as types, and elements containing pairwise similarities between types

ordinariness

two-dimensional matrix of mode numeric with rows as types, columns as subcommunities, and elements containing the ordinariness of types within subcommunities

subcommunity_weights

vector of mode numeric; contains subcommunity weights

type_weights

two-dimensional matrix of mode numeric, with rows as types, columns as subcommunities, and elements containing weights of types within a subcommunity

raw_abundance

[Phylogenetic] two-dimensional matrix of mode numeric with rows as types, columns as subcommunities, and elements containing the relative abundance of present day species

raw_structure

[Phylogenetic] two-dimensional matrix of mode numeric with rows as historical species, columns as present day species, and elements containing historical species lengths within lineages

parameters

[Phylogenetic] tibble containing parameters associated with each historic species in the phylogeny

Details

When calculating phylogenetic diversity either:

  • set partition as the relative abundance of present-day species, with similarity as an object of class phylo, from which the relative abundance and pairwise similarity of historical species will be calculated; or

  • set partition as the relative abundance of historical species, with similarity as the pairwise similarity of historical species.

See Also

metacommunity-class

Examples

Run this code
# NOT RUN {
tree <- ape::rtree(n = 5)
tree$tip.label <- paste0("sp", seq_along(tree$tip.label))
partition <- cbind(a = c(1,1,1,0,0), b = c(0,1,0,1,1))
row.names(partition) <- tree$tip.label
partition <- partition / sum(partition)

a <- metacommunity(partition, tree)
b <- metacommunity(partition)

# }

Run the code above in your browser using DataLab