#All output (including figures/cache/objects/.html) will be generated in a subdirectory of "wd" named "subdir".
# Need to adapt this with here::here
rmd_setup <- function(proj_dir, sub_dir, ...) {
library("knitr")
# Set knitr
if (grepl("/dla_mm", getwd())) {
proj_wd <- paste("/hpc/dla_mm/bogaert", proj_dir, "wd", paste0(sub_dir, "/"), sep="/")
} else {
proj_wd <- paste("/Users/Wouter/Documents/Research_Folder/projects", proj_dir, "wd", paste0(sub_dir, "/"), sep="/")
}
opts_knit$set(aliases=c(h = "fig.height", w = "fig.width", ow = "out.width", fa="fig.asp"),
root.dir = proj_wd)
# Create directories if these do not exist yet
if(!dir.exists(opts_knit$get("root.dir"))) {
dir.create(paste0(opts_knit$get("root.dir"), "figures"), recursive = TRUE)
dir.create(paste0(opts_knit$get("root.dir"), "RData"))
}
# Set environment working directory
setwd(opts_knit$get("root.dir"))
# Figures will be saved in a subdirectory
knitr::opts_chunk$set(warning = FALSE,
message = FALSE,
keep_md = FALSE,
results = "markup",
dpi = 150,
# depreciated because svg does not render as beautiful as pdf
dev = c("png", "pdf"),
fig.path = paste0(getwd(), "/figures/"),
ow='70%', w=7, fa=0.618, fig.align = "center")
#,tidy = FALSE,
#tidy.opts=list(blank = TRUE, width.cutoff = 60), ...)
message(paste0("Working directory is set to: ", getwd(), "."))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.