R/meta_sub_disciplines.R

Defines functions meta_sub_disciplines

Documented in meta_sub_disciplines

#' artlookR sub_disciplines metadata
#'
#' There is only one set of \code{sub_disciplines} 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 \code{sub_disciplines} value used in artlookR. Additionally, the display
#' name and \code{discipline_id} of the discipline of which this \code{sub_discipline} is a part.
#' @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_sub_disciplines()
#' @export
meta_sub_disciplines <- function(...){

  temp <- tbl(myconn, in_schema("public", "sub_disciplines")) %>%
    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,
                 discipline = case_when(temp$discipline_id == 1 ~ "Dance",
                                        temp$discipline_id == 2 ~ "Music",
                                        temp$discipline_id == 3 ~ "Theatre",
                                        temp$discipline_id == 4 ~ "Visual Arts",
                                        temp$discipline_id == 5 ~ "Literary Arts",
                                        temp$discipline_id == 6 ~ "Media Arts"),
                 discipline_id = temp$discipline_id)

  output

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