#! /usr/bin/Rscript --vanilla --default-packages=base,stats,utils

packages = c('knitr','tidyverse','rmarkdown','stevetemplates','stevemisc')

## Now load or install&load all
package.check <- lapply(
  packages,
  FUN = function(x) {
    if (!require(x, character.only = TRUE)) {
      install.packages(x, repos='https://www.freestatistics.org/cran/', lib='~/R/lib')
      library(x, character.only = TRUE)
    }
  }
)

file <- list.files(pattern='article.Rmd')
rmarkdown::render(file)
