/Rmarkdown_workshop

Rmarkdown template with interactive features

Primary LanguageTeX

Rmarkdown_workshop

This is the repository for the RSG Norway workshop introducing RMarkdown.

Here you will find a document (Example.Rmd) with many examples that could be used as a template for your projects.

Overall these are the features included in the document:

  • Combining text and R code: ordered/unordered lists, bold/italics, equations, footnotes.
  • Insert citations: required format and change citation styles.
  • Tables (static and interactive).
  • Figures: convert a figure generated by ggplot to an interactive plot using plotly.
  • Load figures with .png or .jpeg format.
  • Load figures stored as .Rdata.
  • Multi-panel figures
  • Embeded figures in tabs

The output of Example.Rmd is an html document, altough RMarkdown allows to export PDF documents, in this example we will use the html output because it allows to have interactive features.

Feel free to use this document for your own projects, RMarkdown has much more nice features than those covered in this template, feel free to add them and contribute to this repository.

💻 Install required software

  • R version >= 4.0.2

  • RStudio

  • Install the following libraries. This example shows the installation in ubuntu.

sudo apt-get installlibcurl4-openssl-dev
sudo apt-get install libxml2-dev
sudo apt-get install texlive-xetex
sudo apt-get install texlive-fonts-extra

Download this repository

git clone https://github.com/RSG-Norway/Rmarkdown_workshop.git
cd Rmarkdown_workshop

R libraries

The following R packages are required to run the Example.rmd document, you can install these packages within R using the following commands

required.libraries <- c("cowplot",        ## Many (gg)plots in the same frame
                        "dplyr",          ## Data manipulation
                        "DT",             ## Interactive tables
                        "ggplot2",        ## Plotting
                        "ggridges",
                        "grid",           ## Many figures and plots in the same frame
                        "gridExtra",      ## ## Many figures and plots in the same frame
                        "htmlwidgets",    ## Required to visualize/export interactive ggplots
                        "jpeg",           ## Upload figures in jpeg format
                        "palmerpenguins", ## Example dataset
                        "plotly",         ## Converts static ggplot in interactive figures
                        "png",            ## Upload figures in png format
                        "rmarkdown"       ## Utilities
                      )


## Load the required libraries (or install them if they are missing)
for (lib in required.libraries) {
  if (!require(lib, character.only = TRUE)) {
    install.packages(lib)
    suppressPackageStartupMessages(library(lib, character.only = TRUE))
  }
}

In case you are not using RStudio you can render your Rmd files. You can use a script provided in this repository and run it with the following command.

The option -d must be the Rmd file you want to render.

Rscript Render_Rmd_doc.R -d Template_RSG.Rmd

💥 Contact + Report issues

This repository is maintained by Jaime A Castro-Mondragon and the core members of the RSG Norway.

📧 jacmondragon@nykode.com , rsg-norway@iscbsc.org

Twitter: @jaimicore , @RSGNorway