Last updated: r format(Sys.Date(), "%B %d %Y")

Setup

Required Packages

knitr::opts_chunk$set(error = TRUE, message = FALSE, warning = TRUE)

library(here)
library(readr)
library(dplyr)
library(ggplot2)
library(knitr)
library(kableExtra)

Plot and Table Themes

# set global ggplot theme
theme_spacious <- function(font.size = 14, bold = TRUE){
  key.size <- trunc(font.size * .8)
  if (bold == TRUE) {
    face.type <- "bold"
  } else {
    face.type <- "plain"
  }

  theme(text = element_text(size = font.size),
        axis.title.x = element_text(margin = margin(t = 15, r = 0,
                                                    b = 0, l = 0),
                                    face = face.type),
        axis.title.y = element_text(margin = margin(t = 0, r = 15,
                                                    b = 0, l = 0),
                                    face = face.type),
        legend.title = element_text(face = face.type),
        legend.spacing = unit(20, "pt"),
        legend.text = element_text(size = key.size),
        plot.title = element_text(face = face.type, hjust = .5,
                                  margin = margin(b = 10)),
        plot.caption = element_text(hjust = 0, size = key.size,
                                    margin = margin(t = 20)),
        strip.background = element_rect(fill = "white", color = "gray"),
        strip.text = element_text(color = "black",
                                  face = face.type))
}

output_theme <- theme_linedraw() + 
  theme_spacious(font.size = 12) + 
  theme(panel.border = element_rect(color = "gray"),
        axis.line.x = element_line(color = "gray"),
        axis.line.y = element_line(color = "gray"))

theme_set(output_theme)

table_theme <- function(x, digits = 3, title = NULL, note = NULL) {
  kable(x, digits = digits, caption = title) %>%
  kable_classic(position = "left") %>%
  kable_styling(full_width = FALSE, position = "left") %>%
  footnote(general = note)
}

Import Data

data_import <- read_csv(here("folder_path", "filename.csv"))

Get Data Ready For Models




Section Titles without tabs




Section Titles with tabs {.tabset .tabset-pills}

Model


Tables


Figures




Session Info

citation()
sessionInfo()
rm(list = ls())


dr-JT/workflow documentation built on May 5, 2024, 2:08 a.m.