Link: R

R comment style

##:::::::::::::::::::::::::::::::::
## This is the comment
##:::::::::::::::::::::::::::::::::
 
##...................................
## alternative
## comment
##...................................

Custom function header

library(bannerCommenter)
##===============================================================
##                          FUNCTIONS                          ==
##===============================================================
 
# How to use banner commenter
banner("Functions()", "function description line 1", "function description line 2", bandChar = "-", rightSideHashes = 1)
##---------------------------------------------------------------
##                          Functions()                         -
##                  function description line 1                 -
##                  function description line 2                 -
##---------------------------------------------------------------

R syntax style guide

I initially reply on Hadley Wickham’s Style guide · Advanced R., which has been replaced by The tidyverse style guide.

It doesn’t matter whether to use snake case or kebab case, either would work.

R Markdown theme guide

Front matter

---
title: "Documentation"
output:
  html_document:
    css: ~/R/style.css
    highlight: tango
    theme: spacelab
    toc: yes
    toc_depth: 4
    toc_float:
      collapsed: no
---

Alternative: prettydoc

output:
  prettydoc::html_pretty:
    theme: cayman
    highlight: github

Highlight

eranraviv.com/syntax-highlighting-style-in-rmarkdown/ Haddock pygments

Theme

bootswatch.com/3/ Sandstone Spacelab Default

Change font size in Rmarkdown

<style type="text/css">
 
body{ /* Normal  */
      font-size: 12px;
  }
td {  /* Table  */
  font-size: 8px;
}
h1.title {
  font-size: 38px;
  color: DarkRed;
}
h1 { /* Header 1 */
  font-size: 28px;
  color: DarkBlue;
}
h2 { /* Header 2 */
    font-size: 22px;
  color: DarkBlue;
}
h3 { /* Header 3 */
  font-size: 18px;
  font-family: "Times New Roman", Times, serif;
  color: DarkBlue;
}
code.r{ /* Code block */
    font-size: 12px;
}
pre { /* Code block - determines code spacing between lines */
    font-size: 14px;
}
</style>

Differences between R Markdown and R Notebook

The extension is the same. It’s like Jupyter Lab vs Jupyter Notebook. The only differences is the rendering.

R Notebook allows preview the rendering quickly without having to knit. This answer explained clearly with screenshot.

TL;DR: R Notebook is much better.