International College of Digital Innovation, Chiang Mai University
July 3, 2025
RStudio is an integrated development environment (IDE) for R that provides several features and tools to enhance the R programming experience. Here are some reasons why many users choose to use RStudio:
Intuitive Layout: RStudio has a well-organized interface.
Syntax Highlighting: It offers syntax highlighting, which helps in reading and writing code more easily.
Script Editor: You can write and edit R scripts, the features like code completion and error checking.
Console: The built-in console allows you to run R commands interactively.
Viewer Pane: You can visualize plots and interactive outputs within the IDE.
menu Tools
\(\rightarrow\) Global Options...
FiraCode Font
Fira Code is a popular monospaced font designed for programming. Here are some key features and information about it:
Features of Fira Code:
Ligatures: Fira Code includes programming ligatures, which are special combinations of characters that are rendered as single symbols (e.g., !=
, ->
, ==
). This makes code more readable and visually appealing.
Monospaced: As a monospaced font, each character takes up the same amount of horizontal space, which is ideal for aligning code and making it easier to read.
Open Source: Fira Code is open-source and can be freely used and modified. It is available on platforms like GitHub.
Cross-Platform: It can be used on various operating systems, including Windows, macOS, and Linux.
Clear and Readable: The font is designed to be legible at different sizes, making it suitable for long coding sessions.
Quarto is an open-source, next-generation publishing system designed for creating dynamic documents,
reports
presentations
websites
dashboard
Shiny
books
ETC.
Allowing for a more flexible and powerful way to create documents that integrate code, text, tables, videos ,and visualizations depending on the output.
You are install R program.
You are install RStudio.
You are install Quarto.
Warning
This interactive slide cannot run Quarto files (.qmd).
Follow these steps:
Open RStudio: Launch RStudio from your applications or programs menu.
Create a New Quarto Document:
In RStudio, go to the top menu and select: File
\(\rightarrow\) New File
\(\rightarrow\) Quarto Document
This will create a new .qmd
file where you can write your Quarto content.
Note
In this course, we will focus on creating HTML documents/reports with Quarto.
For the final project, you will learn how to create a dashboard with Quarto.
After save file, we can render to recieve the output/report
You can render a qmd file in RStudio into HTML, docx and pdf etc. The output based on your set up
Normally for each Quarto file is composed of 3 main components
YAML header is processed in many stages of the rendering process and can influence the final document in many different ways.
A typical YAML header looks like this, and contains basic metadata about the document and rendering instructions:
YAML Parameter Explanation
title
: The main title of the document. Displayed prominently at the top of the output file and used in the browser tab.author
: The name of the person who wrote the document. This may appear under the title depending on the format.institute
: The organization or affiliation of the author. It can be shown with the author name in the document’s header.date
: The publication or creation date of the document. It can be static (as written here) or dynamically updated.date-format
: Controls the formatting of the date.
long
means a format like “June 26, 2025”short
(e.g., 6/26/2025), medium
, full
date-modified
: Automatically sets the “last modified” date to the current date/time when the document is rendered.format
: Specifies the output format.
html
: Renders the document as a web page. Suitable for publishing online with themes, interactivity, and responsive design.
pdf
: Converts the document into a print-ready PDF using LaTeX. This is ideal for academic papers, reports, and materials that require precise layout and styling.
docx
: Outputs a Microsoft Word document. Useful for collaborative editing, administrative reports, and situations where users prefer Word formatting.
pptx
: Creates a PowerPoint presentation. Each section or slide in your document becomes a slide in the .pptx
file. Useful for formal presentations that require PowerPoint compatibility.
revealjs
: Generates an HTML slideshow presentation using the Reveal.js framework. Great for interactive, browser-based presentations with animations, code, and charts.
dashboard
: Builds a web-based dashboard layout with multiple panels and sections (like plots, tables, and text). Useful for showcasing interactive reports and data visualizations.
Each format serves a different purpose depending on the audience and delivery method of the content. You can also configure many appearance and behavior options specific to each format.
theme
: The visual style of the HTML document.
superhero
is a dark, bold theme from Bootswatch.Another list of theme name from quarto click here
toc
: Enables a Table of Contents in the output.
One of the great things about Quarto is that you don’t need to rely on your word processor to bring your R code, analysis and writing together. Quarto is able to render (almost) all of the text formatting that you are likely to need such as italics, bold, strike-through, super and subscript as well as bulleted and numbered lists, headers and footers, images, links to other documents or web pages and also equations.
Goal | Quarto | output |
---|---|---|
bold text | **text** | text |
italic text | *text* | text |
strikethrough | ~~text~~ | |
superscript | text^2^ | text2 |
subscript | text~2~ | text2 |
Try it in your Quarto
---
title: "RStudio and Quarto"
author: "Somsak Chanaim"
institute: "International College of Digital Innovation, CMU"
date: "03 Jul 2025"
date-format: long
format: html
theme: superhero
toc: true
---
## section
contents...
### subsubsection
contents...
#### subsubsubsection
contents...
##### subsubsubsubsection
contents...
Only for Slide Presentations (PPTX
or revealjs
)
##
: Starts a new slide with a title.
---
: Starts a new slide without a title.
If you want to create a bullet point list of text you can format an unordered list with sub items. Notice that the sub-items need to be indented.
Goal | R markdown | output |
---|---|---|
bold text | **text** | text |
italic text | *text* | text |
strikethrough | ~~text~~ | |
superscript | text^2^ | text2 |
subscript | text~2~ | text2 |
Generate Tables Quickly
Copy a table from Excel or Google Sheets, paste it into tablesgenerator, and generate the corresponding Markdown code.
Code
Remark
path-to-image-here
: You should place your image in the same folder as your .qmd file or create a separate folder for images. This makes it easier to manage and insert image files in the same way.
Note: path-to-image-here
can also be a URL.
If your output contains mathematical symbols, you need to know \(\LaTeX\) commands.
Code
Result
\[ \cos^2(\theta) +\sin^2(\theta) =1 \]
There are many online services you can use, such as hostmath
you can also include links to webpages or other links in your document. Use the following syntax to create a clickable link to an existing webpage.
Example code
Result
In Quarto, a callout is a special block used to highlight content such as tips, warnings, notes, or important information.
Result
Title (Optional)
This is a note callout.
Callout Types (Styles)
Type | Class | Use case |
---|---|---|
note |
.callout-note |
For additional information |
tip |
.callout-tip |
Helpful suggestions or shortcuts |
important |
.callout-important |
Key concepts to remember |
warning |
.callout-warning |
Caution before proceeding |
caution |
.callout-caution |
Potential risks or pitfalls |
With or Without Icons
To embed a YouTube video in an HTML
page or a slide of a Quarto revealjs
presentation, you can use shortcodes
Example Code:
Result
A tabset is a user interface element that lets you organize related content into separate tabs within the same section of a page. Only one tab’s content is visible at a time, and users can switch between tabs by clicking on the tab labels.
Why use tabsets?
To save space by not showing everything at once
To group related information without creating separate sections or pages
To improve readability and user experience, especially in HTML documents, revealjs or dashboards
A column is a vertical section of content placed side by side with other columns. In Quarto, columns help you organize content into multiple parts horizontally within a page or slide.
Why Use Columns?
To make content easier to compare
To improve layout and readability
To present information side by side (e.g., code + output, text + plot)
::::{.columns}
:::{.column width="50%"}
**Instructor**
Dr.Somsak Chanaim
somsak.c@icdi.cmu.ac.th
:::
:::{.column width="50%"}
**Course details**
Day: Mon and Th
Time: 2.45-4.15 PM.
Room: ICB1211
:::
::::
Instructor
Dr.Somsak Chanaim
somsak.c@icdi.cmu.ac.th
Course details
Day: Mon and Th
Time: 2.45-4.15 PM.
Room: ICB1211
This part is about set up your R code, you can
changing our language engine
modifying chunk options, which can be global, local, or engine-specific;
set up outputs
In R markdown, you can put R code in this
Results
[1] 4
We will show some useful chuck options ans you must do it in your R markdown.
Hide source code:
Does not run this chuck
Without setting
Codes
Results
Setting by
fig-height: \<number\>
fig-width: \<number\>
Codes
Results
In the chuck code use command
fig-cap = "any caption word"
GUI
RStudio has keyboard shortcuts. A full list can be found under the menu Tools
\(\rightarrow\) Keyboard Shortcuts Help
. Some of the most useful shortcuts related to Markdown are summarized in Table
Task | Windows & Linux | macOS |
---|---|---|
Insert R chunk | Ctrl+Alt+l | Command+Option+l |
Preview HTML | Ctrl+Shift+K | Command+Shift+K |
Knitr document (knitr) | Ctrl+Shift+K | Command+Shift+K |
Compile PDF | Ctrl+Shift+K | Command+Shift+K |
Run all chunks above | Ctrl+Alt+P | Command+Option+P |
Run current chunk | Ctrl+Alt+C | Command+Option+C |
Run current chunk | Ctrl+Shift+Enter | Command+Shift+Enter |
Run next chunk | Ctrl+Alt+N | Command+Option+N |
Run all chunks | Ctrl+Alt+R | Command+Option+R |
Go to next chunk/title | Ctrl+PgDown | Command+PgDown |
Go to previous chunk/title | Ctrl+PgUp | Command+PgUp |
Example: If we have chuck code
We can use variable values to display or compute within the content.
Content
The value of a + b is \(^\backprime\)r a + b\(^\backprime\).
The value of a / b is \(^\backprime\)r a / b\(^\backprime\).
Result after render.
The value of a + b is 4.
The value of a / b is 0.3333333.
You will get the addins “Write new R markdown of YAML file
The goal of DT is to help you build interactive table.
Example
Rstudio after version 1.4+or after the year 2021, we can use the Visual Markdown Editing menu to product quarto output.
[1] https://docs.posit.co/ide/user/
[3] https://github.com/tonsky/FiraCode
[5] https://www.tablesgenerator.com/