A Contributing a Module

Each module must be produced with bookdown, an R package which allows you to integrate scientific writing (including math, figures, etc.) with executable programming blocks. While bookdown is interfaced through R, very little R knowledge is required to operate it. The scientific writing is done in Markdown and LaTeX, whereas the programming blocks can be written in R, Python, Julia, C++, etc.

Each module should consist of:

  • One Rmd file containing the Markdown/LaTeX text, and short snippets of code which contribute to understanding the text (e.g., loading and displaying parts of datasets, simple calculations), or which can be used to create figures and tables.

  • Any number of external .R, .py, .jl, .cpp, etc. files for anything more complicated, e.g., interdependent and longer functions, data preprocessing files, etc. I strongly recommend that you do not put too much code into Rmd files directly as it makes it much more difficult to organize, debug, and maintain.

  • Do provide links to relevant resources: papers, blogposts, etc. which helped you understand things better, and also any high quality/performance software to use or explore. I’ve tried to provide such resources in my notes; please do update if links are broken, libraries have been superceeded, etc.

For optimal content delivery, please focus on the following:

  1. Creating a clear organization of topics within your module using section/subsection/subsubsection headers.

  2. Setting up the code for examples in a clear and well-organized manner, i.e., what to include directly in the .Rmd file and what goes into external scripts, lots of code comments, informative variable names and consistent naming conventions, etc.

Module content should adhere to the project’s formatting guidelines and git contributing guidelines.

A.1 Structure of the E-Book

The pages of the e-book are all files ending with .Rmd in the root directory of the project. The file [index.Rmd] is the e-book landing page. Other files (e.g., .R script files) can be called from theses pages and are thus indirectly part of the book. This README file is not called by any .Rmd file and is thus not part of the book, but such files are rendered automatically on GitHub from within any subfolder, and are thus very useful for development notes.

To render the e-book:

  1. If you’ve never used R, install it and install the RStudio API. Never use R from its built-in GUI.

  2. Install the R blogdown package.

  3. Clone this GitHub repo onto your local machine.

  4. Open R and set the working directory to the root project folder.

  5. Run the R command

    bookdown::render_book("index.Rmd")

    This will compile the entire e-book. If you only want to render the page you are working on (let’s call it my_module.Rmd), run the command

    bookdown::preview_chapter("my_module.Rmd")

    These commands will generate the desired .html files in the _book subdirectory.

A.2 Resources