R/get_data.R

Defines functions get_donation_data hack_shinra_data get_resident_data

Documented in get_donation_data get_resident_data hack_shinra_data

#' Return various data used in AVALANCHE analyses
#'
#' @param data_table Logical. Return a `data.table`?
#'
#' @return Either a `tibble` or a `data.table`
#' @export
#'
#' @examples
#'
#' get_resident_data(data_table = TRUE)
#'
get_resident_data <- function(data_table = FALSE) {
  residents_per_sector <- db_con("residents_per_sector")

  if (data_table) return(data.table::as.data.table(residents_per_sector))

  tibble::as_tibble(residents_per_sector)
}

#' @export
#' @rdname get_resident_data
hack_shinra_data <- function(data_table = FALSE) {
  shinra_reactor_output <- db_con("shinra_reactor_output")

  if (data_table) return(data.table::as.data.table(shinra_reactor_output))

  tibble::as_tibble(shinra_reactor_output)
}

#' @export
#' @rdname get_resident_data
get_donation_data <- function(data_table = FALSE) {
  donations <- db_con("donations")

  if (data_table) return(data.table::as.data.table(donations))

  tibble::as_tibble(donations)
}
emptyfield-ds/r_packages_test documentation built on Jan. 2, 2022, 12:15 a.m.