MyNixOS website logo
Description

Utilities for using the 'COM(P)ADRE' Matrix Model Database.

Utility functions for interacting with the 'COMPADRE' and 'COMADRE' databases of matrix population models. Described in Jones et al. (2021) <doi:10.1101/2021.04.26.441330>.

Rcompadre

ProjectMain branchDevel branch
License: GPL v3R-CMD-checkR-CMD-check
Project Status: Active – The project has reached a stable, usable state and is being actively developed.codecov
CRAN_Status_Badge

An R package to facilitate working with the COM(P)ADRE Plant and Animal Matrix Population Databases.

Installation

Install the stable release package from CRAN with:

install.packages("Rcompadre")

Install the package from GitHub with:

# install package 'remotes' if necessary
# will already be installed if 'devtools' is installed
install.packages("remotes")

# argument 'build_opts = NULL' only needed if you want to build vignettes
remotes::install_github("jonesor/Rcompadre", build_opts = NULL)

To install from the development branch use:

remotes::install_github("jonesor/Rcompadre", ref = "devel")

Usage

library(Rcompadre)

Fetching a database

Fetch the most recent database version from compadre-db.org with

compadre <- cdb_fetch("compadre") # or use 'comadre' for the animal database

or load from a local .RData file with

compadre <- cdb_fetch("path/to/file/COMPADRE_v.4.0.1.RData")

If you prefer using load() to load your local copy of a legacy database, use as_cdb() to convert it to the CompadreDB class

load("COMPADRE_v.4.0.1.RData") # loads object 'compadre'
compadre <- as_cdb(compadre)

Subsetting

For the most part CompadreDB objects work like a data frame. They can be subset using [, subset() or filter()

# subset to the first 10 rows
compadre[1:10, ]

# subset to the species 'Echinacea angustifolia'
subset(compadre, SpeciesAccepted == "Echinacea angustifolia")

# subset to the species 'Echinacea angustifolia'
filter(compadre, SpeciesAccepted == "Echinacea angustifolia")

Example analysis: calculating population growth rates

First we’ll use the function cdb_flag() to add columns to the database flagging potential issues with the projection matrices, such as missing values, or matrices that don’t meet assumptions like ergodicity, irreducibility, or primitivity.

compadre_flags <- cdb_flag(compadre)

We’ll only be able to calculate population growth rates from matrices that don’t contain missing values, and we only want to use matrices that meet the assumption of ergodicity, so we’ll subset the database accordingly.

compadre_sub <- subset(
  compadre_flags,
  check_NA_A == FALSE & check_ergodic == TRUE
)

Finally, we’ll use the eigs() function from the popdemo package to calculate the population growth rate for every matrix in compadre_sub.

compadre_sub$lambda <- sapply(matA(compadre_sub), popbio::eigs, what = "lambda")

In the code above, the accessor function matA() is used to extract a list of projection matrices (the full matrix, matA) from every row of compadre_sub. There are also accessor functions for the matrix subcomponents (matU(), matF(), matC()), and for many other parts of the database too.

Previous releases

Specific earlier releases of this package can be installed using the appropriate @ tag.

For example to install version 0.1.0:

remotes::install_github("jonesor/[email protected]")

See the Changelog for more details.

Citation

Jones, Owen R., Patrick Barks, Iain M. Stott, Tamora D. James, Sam C. Levin, William K. Petry, Pol Capdevila, et al. 2022. “Rcompadre and Rage – Two R Packages to Facilitate the Use of the COMPADRE and COMADRE Databases and Calculation of Life History Traits from Matrix Population Models.” Methods in Ecology and Evolution. doi: 10.1111/2041-210X.13792.

Contributions

All contributions are welcome. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

There are numerous ways of contributing.

  1. You can submit bug reports, suggestions etc. by opening an issue.

  2. You can copy or fork the repository, make your own code edits and then send us a pull request. Here’s how to do that.

  3. You can get to know us and join as a collaborator on the main repository.

  4. You are also welcome to email us.

Metadata

Version

1.3.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows