R/mocis_contents.R

Defines functions mocis_contents

Documented in mocis_contents

#' Extracts table of contents of a MoCiS object and places in data frame
#'
#' @param mocis_object A list returned from \code{MoCiS::mocis}
#' @return A tibble with columns \code{loc} (locationm), \code{var} (variable) and \code{gen} (genus) and one row for each combination found in \code{mocis_object}
#' @export
#' @examples


mocis_contents <- function(mocis_object){
  mocis_object %>%
    map_depth(2, names) %>%
    unlist() %>%
    enframe() %>%
    separate(name, into = c("loc", "gen")) %>%
    mutate(gen = str_sub(gen, 1, 4)) %>%
    rename(var = value) %>%
    arrange(var) %>% 
    na.omit()
}
NRM-MOC/MoCiS.tools documentation built on March 9, 2021, 10:56 a.m.