How to install and use Quarto with RStudio on a RONIN Machine
Quarto is an open-source tool designed for dynamic documents and reproducible research.
With Quarto, users can write documents in Markdown, LaTeX, and RMarkdown, incorporating code chunks for data analysis, visualization, and other computational tasks. These documents can then be rendered into various formats, including HTML, PDF, and Word, ensuring flexibility in sharing and publishing research findings.
Quarto is useful for researchers, academics, data scientists, and anyone else who needs to create documents that combine text, code, and output in a coherent and reproducible manner. It streamlines the process of conducting analyses, documenting methodologies, and presenting results, making it easier to collaborate and share findings with others.
While Quarto can be used with a variety of tools and IDEs including VS Code, Jupyter Notebooks, RStudio and other text editors, this tutorial will focus on how to install and use Quarto with RStudio on your RONIN machine. Instructions for other tools can be found on the Quarto website here.
Step 1: Create an ubuntu machine in RONIN
Quarto can be used on a number of operating systems, for this blog we will be using Ubuntu 22.04 as our base operating system.
If you need help learning how to create a machine in RONIN - please see our tutorial here.
Step 2: Connect to your machine's terminal and install Quarto
The latest download link for Ubuntu can be found at Quarto's website here. Please replace the version numbers as needed in the code snippets below.
Download the latest Quarto Ubuntu installation file:
wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.4.553/quarto-1.4.553-linux-amd64.deb
Install Quarto:
sudo dpkg -i quarto-1.4.553-linux-amd64.deb
Step 3: Install R and RStudio
If you are using RONIN LINK to connect to your RONIN machine (which is recommended), you can simply use the RStudio "LINK" button in the "Connect to your machine" modal to install R and RStudio. Once the installation is complete it should open RStudio in your browser.
If you are not using RONIN LINK, you will need to install R and RStudio - some general installation instructions can be found here. We recommend creating an rstudio user with a password and home directory that RStudio can run from.
Step 4: Install all of the other required dependencies
Back in your machine's terminal, run the following commands to install of the required dependencies and perform the necessary configuration for Quarto to run properly with RStudio.
Build tools required for installing R packages:
sudo apt install build-essential libssl-dev libxml2-dev libcurl4-openssl-dev libfontconfig1-dev zlib1g-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev
Install TinyTex for creating PDFs:
sudo -u rstudio quarto install tinytex
Download an example Quarto document
sudo -u rstudio bash -c "wget -P /home/rstudio https://quarto.org/docs/get-started/hello/rstudio/_hello.qmd"
Step 5: Install the required R packages
Quarto, and the example file, relies upon two R packages, tidyverse
, and palmerpenguins
to run. You can also install the quarto
R package - this is not required but means that you can run quarto commands from the R console.
Login to your RStudio in the browser (username and password are both rstudio
by default if installed with RONIN LINK) and run the following commands in the R Console to install the required packages:
install.packages("tidyverse")
install.packages("palmerpenguins")
install.packages("quarto")
Note: If you receive any execution errors in RStudio relating to the temporary directory, you may need to run this command in your terminal: sudo mount -o remount,exec /tmp
Step 6: Open and test the example Quarto file
- The example Quarto file you downloaded (_hello.qmd) should be in the default /home/rstudio folder in the files viewer. Double click to open it.
- To test that Quarto is installed succesfully, click on the "render" button. It should convert the Quarto document to a html document and try and open it in your browser. You may need to click "Try Again" if the popup window is blocked.
The popup window should show the final html file as follows:
You can create a pdf file instead of a html file by editing the format option in the YAML header from html
to pdf
. If you click render again, Quarto will instead create a pdf file and the popup window should show you the final PDF like so:
Step 7: Create your own Quarto file
Once you've made sure Quarto is working as expected, you can create your own new quarto document by navigating to File > New File > Quarto Document
You can then use the template to build out your Quarto document as needed:
Since Quarto relies upon Markdown, you can see a tutorial of how to write markdown from one of our previous blog posts:
Also check out the below video to see how to get started with Quarto: