R/extract_tourism.R

#' @export
extract_tourism <- function(path,
                            sheet = "Tourism") {

  df <- openxlsx::read.xlsx(xlsxFile = path, sheet = sheet)
  df <- df[, 1:5]
  names(df) <- c('year', 'gva', 'total', 'perc', 'overlap')
  df <- dplyr::mutate(df, year = as.integer(year))

  # validate
  cols = rbind(
    data.frame(),
    list("year", "integer"),
    list("gva", "numeric"),
    list("total", "numeric"),
    list("perc", "numeric"),
    list("overlap", "numeric"),
    stringsAsFactors = FALSE
  )
  names(cols) <- c("name", "type")

  validate(
    df,
    cols = cols,
    class_name = "tourism"
  )

}
DCMSstats/eegva documentation built on May 31, 2019, 2:44 p.m.