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
Rmdfile 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 intoRmdfiles 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:
Creating a clear organization of topics within your module using section/subsection/subsubsection headers.
Setting up the code for examples in a clear and well-organized manner, i.e., what to include directly in the
.Rmdfile 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:
If you’ve never used R, install it and install the RStudio API. Never use R from its built-in GUI.
Install the R blogdown package.
Clone this GitHub repo onto your local machine.
Open R and set the working directory to the root project folder.
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 commandbookdown::preview_chapter("my_module.Rmd")These commands will generate the desired
.htmlfiles in the_booksubdirectory.
A.2 Resources
R Markdown: The bookdown e-book the Definitive R Markdown Guide and the R Markdown Cookbook.
Content: The LaTeX code to generate the course’s slides and example code.
Git: The Pro Git book, and a quick tutorial here.