Open iamstein opened 1 year ago
For adding a caption, this is my favorite code now:
Rmd_name = "Rmd_Name.Rmd"
caption = paste(c("Rmd_Directory",
Rmd_name,
str_replace(Rmd_name, ".Rmd$", ".html"),
paste(Sys.time())),
collapse = "\n")
ggcaption = list(labs(caption = caption),
theme(plot.caption = element_text(hjust = 0.5)))
Then, later on in the code, I can just write:
g = g + ggcaption
There are lots of little tips I find and always forget and thought it'd be nice to compile them in a page. It could be another Resource. Pasting a bit of it below to give you an idea.
title: Rmarkdown Tips author: "Andy Stein" date: "
r format(Sys.time(), '%d %B, %Y')
" output: bookdown::html_document2: toc: yes toc_float: yes code_folding: hide bibliography: Bibliography.bibCommon Errors
Header - Default
Text
Displaying messages and warnings by default
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
Number of digits to display in inline code by default
Figures
Set default size
knitr::opts_chunk$set(fig.height = 4, fig.width = 8)
How to cross-reference and add caption
Tables
data.table vs kable
Set default number of rows
Change number of rows
How to cross-reference and add caption
References