R: Visualize Dashboards with Quarto

Author

David Gerbing

Published

May 19, 2026, 10:30 am

Setup

Accomplish R dashboards via Quarto. The Quarto website displays a gallery of possibilities. The website also provides more detailed dashboard instructions. Here, we cover the basics.

To construct a dashboard with R, do so by creating a type of document called Quarto. A distinguishing characteristic of a Quarto document is that ordinary text is separated from computer code, such as R code. When the document is created, that is, rendered, the computer code is run, and the output displayed in the document interwoven with the provided text. The following examples show how to construct this R code within the document in the context of creating dashboards.

Basic Dashboard

Template: R_dashboard.qmd

This dashboard consists of four figures, each generated as a data visualization from a corresponding chunk of R code.

Figure 1: Standard R dashboard.

Here is the Quarto (.qmd) file opened in RStudio with Source editing mode. When rendered, this text file generates the dashboard in Figure 1.

Figure 2: Quarto file in Source editing mode that generates the dashboard when rendered.

Create other document types with other formats, including html, docx, pptx, and pdf.

To create a dashboard, create a Quarto document with the .qmd file type. Begin your document with what is called YAML, basic document formatting instructions enclosed in a block of code within beginning and ending lines of three hyphes ---. Specify the format as dashboard.

Next, to generate lessR visualizations, include the following three lines in the first chunk of R code.

suppressPackageStartupMessages(library(lessR))
style(suggest=FALSE, quiet=TRUE)   # no suggestions and text output
style(lab_cex=1.6, axis_cex=1.3)          # enlarge axis and value labels

Each of the four figures in the dashboard was created by running a single line of R code. To distinguish text from computer code, embed one or more lines of code as illustrated in Figure 2. The three single backlashes ``` opening and ending lines of each code chunk can be quickly generated by the CTRL+Alt+I or CMD+Option+I key combination, or, enter the information manually.

The lines of code in this example apply to R, but code from other languages, such as Python, can also be embedded.

By default, construct your dashboard row-by-row. To create a dashboard row in your Quarto document, enter the word Row as a second-level header indicated by ##followed by the specified height of the row.

To create a free-form dashboard, enter the instructions directly in Source edit mode, or do the following in Visual edit mode. Then, follow these four steps to create a row of information in your dashboard.

  1. Enter the word: Row

  2. Go to the Paragraph Style menu on the menu bar, right before the bullet point menu, usually with the word Normal displayed. Select Header 2. (Markdown code indicates a second-level header by two # signs preceding it.)

  3. Go to the Format menu and select Edit Attributes... at the bottom.

  4. Under the entry for Other, add height=50% or whatever percentage of the overall height of the window you wish for this row of the dashboard to occupy.

TipAdd content to the dashboard

Now that the row is declared, populate the row under the Row header by specifying one or more items to display on your dashboard.

For example, if you place two items, such as two R code chunks for two data visualizations, under the row header you created, then that Row will contain two displays. If you have two rows, and two items under each row, then the dashboard will contain four separate displays as in Figure 1.

MarkDown Box Dashboard

Template: R_MarkDownBox.qmd

This dashboard consists of two data visualizations from the corresponding R code chunks and two free-form text boxes called MarkDown boxes. The purpose is to provide commentary and results regarding the displayed visualizations.

Figure 3: R dark themed dashboard with Mark Down Boxes.

Notice that R code can be embedded within the text, what is called inline code, by placing a code statement within `r    `. To compute a statistic such as the mean or the sum, need to incorporate na.rm=TRUE in the function call, which means to remove missing data, NAs, before computing the statistic. Otherwise, one missing data value causes the computation of the statistic to return NA, that is, missing.

Figure 4: Quarto file in Source editing mode that generates the markdown dashboard when rendered.

To create a free-form markdown box dashboard, enter the instructions from the example within RStudio directly in Source edit mode with any needed modifications, or do the following in Visual edit mode.

  1. From the insert menu, select Div….

  2. In the Classes field, enter .card.

  3. As an option, in the Other field, add a title with title=xxx where xxx is your title.

  4. In the gray box that appears, enter the content you wish to display, one or more sentences.

Place as many markdown boxes as you wish in the row, or interspersed with other content as well. The height of the markdown boxes and other content is determined by the height of the row set in the Row header. As always, move to Source mode to view the created markdown directly.