R/meta_networks.R

Defines functions meta_networks

Documented in meta_networks

#' artlookR Networks metadata
#'
#' There is only one set of \code{networks} 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 and levels (which are also the artlookR id numbers) for each \code{networks} value used in artlookR.
#' @details * Only Chicago uses the networks table because it's the only district with a Network structure.
#'
#' * You will need to run the \code{connection.R} script and create a connection object named \code{myconn} for this script to run.
#'
#' * The code orders the network names in a sensible way that is different than how artlookR stores them.
#' @examples meta_network()
#' @export
meta_networks <- function(...){

  temp <-  tbl(myconn, in_schema("public", "networks")) %>%
    select(id, name) %>%
    collect %>%
    arrange(name) %>%
    mutate(num = as.numeric(gsub("[^0-9]", "", name)),
           nam = gsub("[0-9]", "", name)) %>%
    arrange(nam, num)

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

  output

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