# Docker Container R
### Environment ====================================================================================
options("width" = 110)

project_name <- gsub("(.*)_.*", "\\1", basename(params[["project_directory"]]))
output_directory <- params[["output_directory"]]
dir.create(path = output_directory, recursive = TRUE, showWarnings = FALSE, mode = "0775")


### Load packages ==================================================================================
library(here)

suppressPackageStartupMessages({
  library(knitr)
  library(ragg)
  library(ggplot2)
  library(ggtext)
  library(patchwork)
  library(data.table)
})


### knitr settings =================================================================================
opts_chunk$set(
  eval = TRUE,
  include = TRUE,
  echo = FALSE,
  warning = FALSE,
  message = FALSE,
  dpi = 120,
  tidy = FALSE,
  crop = TRUE,
  autodep = TRUE,
  results = "asis",
  fig.align = "center",
  width = getOption("width"),
  comment = "#>",
  # fig.path = file.path(output_directory, "images/"), 
  dev = "ragg_png"
)


### Define theme ===================================================================================
options(
  ggplot2.discrete.colour = function(...) scale_colour_viridis_d(..., begin = 0.15, end = 0.85),
  ggplot2.discrete.fill = function(...) scale_fill_viridis_d(..., begin = 0.15, end = 0.85),
  ggplot2.continuous.colour = function(...) scale_colour_viridis_c(..., begin = 0.15, end = 0.85),
  ggplot2.continuous.fill = function(...) scale_fill_viridis_c(..., begin = 0.15, end = 0.85)
)
theme_set(
  theme_minimal(base_family = "Latin Modern Sans") +
    theme(
      plot.title.position = "plot",
      plot.caption.position = "plot",
      plot.title = element_markdown(),
      plot.subtitle = element_markdown(face = "italic", size = rel(0.8)),
      plot.caption = element_markdown(face = "italic", size = rel(0.5)),
      axis.title.x = element_markdown(),
      axis.text.x = element_markdown(),
      axis.title.y = element_markdown(),
      axis.text.y = element_markdown()
    )
)


### Source functions ===============================================================================

Summary

R session information

session_info()


mcanouil/mctemplates documentation built on Feb. 25, 2021, 5:17 p.m.