Skip to content

Commit

Permalink
edit documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
soniamitchell committed Jan 5, 2019
1 parent 9dc9012 commit 55ef149
Show file tree
Hide file tree
Showing 16 changed files with 352 additions and 178 deletions.
20 changes: 14 additions & 6 deletions R/class-distance.R
Expand Up @@ -6,12 +6,20 @@
#' @rdname distance-class
#' @exportClass distance
#'
#' @field distance object of class \code{matrix}.
#' @field datID object of class \code{character}.
#' @field components object of class \code{list}.
#' @field distance two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as types, and elements containing the pairwise
#' distance of types
#' @field datID object of class \code{character} describing the class of
#' distance / similarity being used, e.g. "naive", "taxonomic", and so on
#' @field components list containining the components necessary to calculate
#' similarity. This list is empty when \code{precompute_dist = TRUE} when
#' calculating distance. When a pairwise distance matrix is too large and
#' \code{precompute_dist = FALSE}, this list contains all the information
#' required to calculate pairwise distance between types
#'
setClass("distance", slots = c(distance = "matrix",
datID = "character",
components = "list"))
setClass("distance",
slots = c(distance = "matrix",
datID = "character",
components = "list"))


28 changes: 19 additions & 9 deletions R/class-metacommunity.R
Expand Up @@ -9,27 +9,37 @@ setOldClass("phylo")
#'
#' @field type_abundance two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as subcommunities, and elements containing
#' relative abundances of types in subcommunities. In the phylogenetic case,
#' 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.
#' @field similarity object
#' @field similarity_components object
#' @field similarity_parameters object
#' is calculated from the proportional abundance of present day species
#' @field similarity two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as types, and elements containing the pairwise
#' similarity of types
#' @field similarity_components list containining the components necessary to
#' calculate similarity. This list is empty when \code{precompute_dist = TRUE}
#' when calculating distance. When a pairwise distance matrix is too large and
#' \code{precompute_dist = FALSE}, this list contains all the information
#' required to calculate pairwise distance between types
#' @field similarity_parameters list containining parameters associated with
#' converting pairwise distances to similarities (the \code{dist2sim()}
#' arguments)
#' @field ordinariness two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as subcommunities, and elements containing the
#' ordinariness of types within subcommunities
#' @field subcommunity_weights \code{vector} of mode \code{numeric}; contains
#' @field subcommunity_weights \code{vector} of mode \code{numeric} containing
#' subcommunity weights
#' @field type_weights two-dimensional \code{matrix} of mode \code{numeric},
#' with rows as types, columns as subcommunities, and elements containing
#' weights of types within a subcommunity
#' @field datID object of class \code{character} describing the class of
#' distance / similarity being used, e.g. "naive", "taxonomic", and so on
#' @field raw_abundance [Phylogenetic] two-dimensional \code{matrix} of mode
#' \code{numeric} with rows as types, columns as subcommunities, and elements
#' containing the relative abundance of present day species
#' @field raw_structure [Phylogenetic] two-dimensional \code{matrix} of mode
#' \code{numeric} with rows as historical species, columns as present day
#' species, and elements containing historical species lengths within lineages
#' @field parameters [Phylogenetic] \code{tibble} containing parameters
#' @field parameters [Phylogenetic] \code{data.frame} containing parameters
#' associated with each historic species in the phylogeny
#'
setClass("metacommunity",
Expand All @@ -40,8 +50,8 @@ setClass("metacommunity",
ordinariness = "matrix",
subcommunity_weights = "numeric",
type_weights = "matrix",
datID = "character",
raw_abundance = "matrix",
raw_structure = "matrix",
parameters = "data.frame",
datID = "character"))
parameters = "data.frame"))

40 changes: 20 additions & 20 deletions R/class-powermean.R
Expand Up @@ -6,31 +6,32 @@
#' @rdname powermean-class
#' @exportClass powermean
#'
#' @field results \code{matrix} of mode \code{numeric}; contains values
#' calculated from diversity-term values output from \code{raw_alpha()},
#' \code{norm_alpha()}, \code{raw_rho()}, \code{norm_rho()}, or
#' \code{raw_gamma()}. An object of class \code{tibble}, with columns:
#' \code{measure}, (raw alpha, norm alpha, raw rho, etc.),
#' \code{q} (parameter of conservatism),
#' \code{type_level} (),
#' \code{type_name} (label attributed to type),
#' \code{partition_level} (level of diversity, \emph{i.e.} subcommunity),
#' \code{partition_name} (label attributed to partition), and
#' \code{diversity}
#' @field results \code{data.frame} containing rdiversity output
#' @field measure object of class \code{character} naming the diversity
#' measure being calculated
#' @field type_abundance two-dimensional \code{matrix} of mode \code{numeric};
#' contains proportional abundance of \emph{types} in the subcommunity
#' as a fraction of the metacommunity as a whole (in the phylogenetic case,
#' this corresponds to the proportional abundance of historic species, which
#' is calculated from the proportional abundance of present day species)
#' @field ordinariness two-dimensional \code{matrix} of mode \code{numeric};
#' contains ordinariness of types
#' @field subcommunity_weights \code{vector} of mode \code{numeric}; contains
#' @field ordinariness two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as subcommunities, and elements containing the
#' ordinariness of types within subcommunities
#' @field subcommunity_weights \code{vector} of mode \code{numeric} containing
#' subcommunity weights
#' @field type_weights two-dimensional \code{matrix} of mode \code{numeric};
#' contains weight of types within a subcommunity
#' @field datID class of similarity, which can be taxonomic, phylogenetic, or
#' naive
#' @field parameters parameters associated with calculating similarity
#' @field type_weights two-dimensional \code{matrix} of mode \code{numeric},
#' with rows as types, columns as subcommunities, and elements containing
#' weights of types within a subcommunity
#' @field datID object of class \code{character} describing the class of
#' distance / similarity being used, e.g. "naive", "taxonomic", and so on
#' @field similarity_components list containining the components necessary to
#' calculate similarity. This list is empty when \code{precompute_dist = TRUE}
#' when calculating distance. When a pairwise distance matrix is too large and
#' \code{precompute_dist = FALSE}, this list contains all the information
#' required to calculate pairwise distance between types
#' @field similarity_parameters list containining parameters associated with
#' converting pairwise distances to similarities (the \code{dist2sim()}
#' arguments)
#'
#' @references Reeve, R., T. Leinster, C. Cobbold, J. Thompson, N. Brummitt,
#' S. Mitchell, and L. Matthews. 2014. How to partition diversity.
Expand All @@ -43,7 +44,6 @@ setClass("powermean", slots = c(results = "matrix",
subcommunity_weights = "vector",
type_weights = "matrix",
datID = "character",
parameters = "list",
similarity_components = "list",
similarity_parameters = "list"))

Expand Down
40 changes: 20 additions & 20 deletions R/class-relativeentropy.R
Expand Up @@ -6,31 +6,32 @@
#' @rdname relativeentropy-class
#' @exportClass relativeentropy
#'
#' @field results object of class \code{matrix} of mode \code{numeric}; contains
#' diversity term values output from \code{raw_beta()} or \code{norm_beta()}
#' @field measure measure
#' An object of class \code{tibble}, with columns:
#' \code{measure}, (raw alpha, norm alpha, raw rho, etc.),
#' \code{q} (parameter of conservatism),
#' \code{type_level} (),
#' \code{type_name} (label attributed to type),
#' \code{partition_level} (level of diversity, \emph{i.e.} subcommunity),
#' \code{partition_name} (label attributed to partition), and
#' \code{diversity}
#' @field results \code{data.frame} containing rdiversity output
#' @field measure object of class \code{character} naming the diversity
#' measure being calculated
#' @field type_abundance two-dimensional \code{matrix} of mode \code{numeric};
#' contains proportional abundance of \emph{types} in the subcommunity
#' as a fraction of the metacommunity as a whole (in the phylogenetic case,
#' this corresponds to the proportional abundance of historic species, which
#' is calculated from the proportional abundance of present day species)
#' @field ordinariness two-dimensional \code{matrix} of mode \code{numeric};
#' contains ordinariness of types
#' @field subcommunity_weights \code{vector} of mode \code{numeric}; contains
#' @field ordinariness two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as subcommunities, and elements containing the
#' ordinariness of types within subcommunities
#' @field subcommunity_weights \code{vector} of mode \code{numeric} containing
#' subcommunity weights
#' @field type_weights two-dimensional \code{matrix} of mode \code{numeric};
#' contains weight of types within a subcommunity
#' @field datID class of similarity, which can be taxonomic, phylogenetic, or
#' naive
#' @field parameters parameters associated with calculating similarity
#' @field type_weights two-dimensional \code{matrix} of mode \code{numeric},
#' with rows as types, columns as subcommunities, and elements containing
#' weights of types within a subcommunity
#' @field datID object of class \code{character} describing the class of
#' distance / similarity being used, e.g. "naive", "taxonomic", and so on
#' @field similarity_components list containining the components necessary to
#' calculate similarity. This list is empty when \code{precompute_dist = TRUE}
#' when calculating distance. When a pairwise distance matrix is too large and
#' \code{precompute_dist = FALSE}, this list contains all the information
#' required to calculate pairwise distance between types
#' @field similarity_parameters list containining parameters associated with
#' converting pairwise distances to similarities (the \code{dist2sim()}
#' arguments)
#'
#' @references Reeve, R., T. Leinster, C. Cobbold, J. Thompson, N. Brummitt,
#' S. Mitchell, and L. Matthews. 2014. How to partition diversity.
Expand All @@ -43,7 +44,6 @@ setClass("relativeentropy", slots = c(results = "matrix",
subcommunity_weights = "vector",
type_weights = "matrix",
datID = "character",
parameters = "list",
similarity_components = "list",
similarity_parameters = "list"))

Expand Down
17 changes: 13 additions & 4 deletions R/class-similarity.R
Expand Up @@ -6,10 +6,19 @@
#' @rdname similarity-class
#' @exportClass similarity
#'
#' @field similarity object of class \code{matrix}.
#' @field datID object of class \code{character}.
#' @field components object of class \code{list}.
#' @field parameters object of class \code{list}.
#' @field similarity two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as types, and elements containing the pairwise
#' similarity of types
#' @field datID object of class \code{character} describing the class of
#' distance / similarity being used, e.g. "naive", "taxonomic", and so on
#' @field components list containining the components necessary to calculate
#' similarity. This list is empty when \code{precompute_dist = TRUE} when
#' calculating distance. When a pairwise distance matrix is too large and
#' \code{precompute_dist = FALSE}, this list contains all the information
#' required to calculate pairwise distance between types
#' @field parameters list containining parameters associated with
#' converting pairwise distances to similarities (the \code{dist2sim()}
#' arguments)
#'
setClass("similarity", slots = c(similarity = "matrix",
datID = "character",
Expand Down
17 changes: 3 additions & 14 deletions R/metacommunity.R
@@ -1,17 +1,6 @@
#' Metacommunity
#'
#' Functions to generate a \code{metacommunity} object.
#'
#' When calculating phylogenetic diversity either:
#' \itemize{
#' \item set \code{partition} as the relative abundance of terminal taxa,
#' in which case \code{similarity} (the pairwise similarity of historical species) is calculated from \code{phy2branch()} and
#' \code{dist2sim()}; or
#' \item set \code{partition} as the relative abundance of historical species,
#' with \code{similarity} (the pairwise similarity of historical species) is
#' calculated from \code{phy2branch()} and
#' \code{dist2sim()}.
#' }
#'
#' @field type_abundance two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as subcommunities, and elements containing
Expand All @@ -24,7 +13,7 @@
#' @field ordinariness two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as subcommunities, and elements containing the
#' ordinariness of types within subcommunities
#' @field subcommunity_weights \code{vector} of mode \code{numeric}; contains
#' @field subcommunity_weights \code{vector} of mode \code{numeric} containing
#' subcommunity weights
#' @field type_weights two-dimensional \code{matrix} of mode \code{numeric},
#' with rows as types, columns as subcommunities, and elements containing
Expand All @@ -45,10 +34,10 @@
#' @param partition two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as subcommunities, and elements containing
#' the relative abundances of types in subcommunities. For phylogenetic
#' diversity, see \emph{Details}.
#' diversity, see \emph{Details}
#' @param similarity (optional) two-dimensional \code{matrix} of mode
#' \code{numeric}, with rows as types, columns as types, and elements
#' containing the pairwise similarity between types.
#' containing the pairwise similarity between types
#'
#' @return \code{metacommunity()} returns an object of class
#' \code{metacommunity} (see \emph{Fields}).
Expand Down
49 changes: 39 additions & 10 deletions R/powermean.R
@@ -1,16 +1,45 @@
#' Calculate power mean
#'
#' Functions to check if an object is a \code{powermean}, or coerse an object
#' into a \code{powermean}; for \code{raw_alpha()}, \code{norm_alpha()},
#' \code{raw_rho()}, \code{norm_rho()}, or \code{raw_gamma()}.
#' Functions to coerse an object into a \code{powermean} (\code{raw_alpha()},
#' \code{norm_alpha()}, \code{raw_rho()}, \code{norm_rho()}, and/or
#' \code{raw_gamma()}).
#'
#' @param tag measure
#' @param results \code{matrix} of mode \code{numeric}; contains values
#' calculated from diversity-term functions \code{norm_alpha()},
#' \code{raw_alpha()}, \code{raw_rho()}, \code{norm_rho()}, and
#' \code{raw_gamma()}
#' @param meta object of class \code{metacommunity}; contains proportional
#' abundance of types, pair-wise similarity, and other associated variables.
#' @param results \code{data.frame} containing rdiversity outputs associated
#' with \code{norm_alpha()}, \code{raw_alpha()}, \code{raw_rho()},
#' \code{norm_rho()}, and/or \code{raw_gamma()}
#' @param meta object of class \code{metacommunity} containing the proportional
#' abundance of types, pair-wise similarity, and other associated variables
#' @param tag object of class \code{character} naming the diversity measure
#' being calculated
#'
#' @field results \code{data.frame} containing rdiversity outputs associated
#' with \code{norm_alpha()}, \code{raw_alpha()}, \code{raw_rho()},
#' \code{norm_rho()}, and/or \code{raw_gamma()}
#' @field measure object of class \code{character} naming the diversity
#' measure being calculated
#' @field type_abundance two-dimensional \code{matrix} of mode \code{numeric};
#' contains proportional abundance of \emph{types} in the subcommunity
#' as a fraction of the metacommunity as a whole (in the phylogenetic case,
#' this corresponds to the proportional abundance of historic species, which
#' is calculated from the proportional abundance of present day species)
#' @field ordinariness two-dimensional \code{matrix} of mode \code{numeric}
#' with rows as types, columns as subcommunities, and elements containing the
#' ordinariness of types within subcommunities
#' @field subcommunity_weights \code{vector} of mode \code{numeric} containing
#' subcommunity weights
#' @field type_weights two-dimensional \code{matrix} of mode \code{numeric},
#' with rows as types, columns as subcommunities, and elements containing
#' weights of types within a subcommunity
#' @field datID object of class \code{character} describing the class of
#' distance / similarity being used, e.g. "naive", "taxonomic", and so on
#' @field similarity_components list containining the components necessary to
#' calculate similarity. This list is empty when \code{precompute_dist = TRUE}
#' when calculating distance. When a pairwise distance matrix is too large and
#' \code{precompute_dist = FALSE}, this list contains all the information
#' required to calculate pairwise distance between types
#' @field similarity_parameters list containining parameters associated with
#' converting pairwise distances to similarities (the \code{dist2sim()}
#' arguments)
#'
#' @return \code{powermean(x)} returns an object of class \code{powermean}.
#' @include class-powermean.R
Expand Down

0 comments on commit 55ef149

Please sign in to comment.