R/cdb_metadata.R

Defines functions cdb_metadata

Documented in cdb_metadata

#' Extract metadata from a COM(P)ADRE database
#'
#' Extract a tibble with only metadata information from a CompadreDB object, by
#' dropping the matrix column "mat".
#'
#' @param cdb A CompadreDB object
#'
#' @return Tibble with all metadata columns of \code{cdb}
#'
#' @author Gesa Romer <gesa.roemer@@gmail.com>
#'
#' @family data acquisition
#'
#' @details Transforms the large CompadreDB object into a tibble and drops the
#' matrix column ("mat").
#'
#' @examples
#' Compadre_metadata <- cdb_metadata(Compadre)
#'
#' @export cdb_metadata
cdb_metadata <- function(cdb) {
  cdb <- as_tibble(cdb)
  i <- which(names(cdb) == "mat")
  if (length(i) == 0) stop("argument cdb does not contain a column 'mat'")
  cdb <- cdb[, -i]
  return(cdb)
}

Try the Rcompadre package in your browser

Any scripts or data that you put into this service are public.

Rcompadre documentation built on Oct. 17, 2024, 1:07 a.m.