R/meta_community.R

Defines functions meta_community

Documented in meta_community

#' artlookR communities
#'
#' There is only one set of \code{communities} used across the entire artlookR platform (i.e., this table is listed in the
#' \code{public} schema). #' Because of that there is no requirement in this function to identify a \code{comm_name}.
#' @return A list with the label names, levels, artlookR id numbers for each value in the \code{communities} table (i.e., each
#' community that has a schema in artlookR.
#' @details * There is, at present, no \code{display_name} variable in the table.
#'
#'  * 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_community()
#' @export
meta_community <- function(...){

  temp <- tbl(myconn, in_schema("public", "communities")) %>%
    arrange(id) %>%
    select(level = "name",
           id) %>%
    collect %>%
    mutate(label = case_when(level == "neworleans" ~ "New Orleans",
                             level == "portlandmetro" ~ "Portland",
                             level == "swpa" ~ "Southwest Pennsylvania",
                             level == "maryland" ~ "Baltimore",
                             TRUE ~ str_to_title(str_replace_all(level, "_", " "))))

  communities <- list(label = temp$label,
                      level = temp$level,
                      id = temp$id)

  communities

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