knitr::opts_chunk$set(
  message = FALSE,
  warning = FALSE, dev = c("png", "cairo_pdf"),
  echo = FALSE,
  fig.retina = 2,
  fig.width = 10,
  fig.height = 6,
  fig.path = "prod/charts/"
)
library(gt)
library(stringi)
library(hrbrthemes)
library(googledrive)
library(tidyverse)

# ensure fonts are available
extrafont::loadfonts("postscript", quiet = TRUE)
extrafont::loadfonts("pdf", quiet = TRUE)

analysis code goes here -------------------------------------------------

Upload to production ----------------------------------------------------

googledrive::drive_auth()

# locate the folder
gdrive_prod_folder <- googledrive::as_id(params$gdrive_folder_url)

# clean it out
gdrls <- googledrive::drive_ls(gdrive_prod_folder)
if (nrow(gdrls) > 0) {
  dplyr::pull(gdrls, id) %>%
    purrr::walk(~googledrive::drive_rm(googledrive::as_id(.x)))
}

# upload new
list.files(here::here("prod/charts"), recursive = TRUE, full.names = TRUE) %>%
  purrr::walk(googledrive::drive_upload, path = gdrive_prod_folder)


hrbrmstr/markdowntemplates documentation built on May 17, 2019, 5:10 p.m.