R/meta_approaches.R

Defines functions meta_approaches

Documented in meta_approaches

#' artlookR approaches metadata
#'
#' @param comm_name The community name as recognized by artlookR
#' @return A list with the label names, levels, artlookR id numbers for each value in the \code{approaches} table,
#' any definitions available for that community, and hidden status of the \code{approaches} table metadata.
#' @details You will need to run the \code{connection.R} script and create a connection object named \code{myconn} for this script to run.
#' @examples meta_approaches("chicago")
#' @export
meta_approaches <- function(comm_name) {

  temp <- tbl(myconn, in_schema(comm_name, "approaches")) %>%
    arrange(position) %>%
    select(display_name, name, id, definition, hidden) %>%
    collect

  output <- list(label = case_when(is.na(temp$display_name) ~ str_to_title(str_replace_all(temp$name, "_", " ")),
                                   TRUE ~ temp$display_name),
                 level = temp$name,
                 id = temp$id,
                 definition = temp$definition,
                 hidden = temp$hidden)

  output

}
Ingenuity-Inc/artlookR documentation built on May 18, 2022, 12:33 a.m.