This tutorial introduces R Notebooks as a powerful tool for combining code, output, and narrative in a single, dynamic document. It shows how to use R Notebooks with Markdown to streamline analysis, improve transparency, and enhance reproducibility in linguistic and data science research.
This tutorial is intended for researchers working with language data, particularly those in the humanities and social sciences. It is especially useful for beginner to intermediate R users who want to document their work more clearly and share it in a readable and executable format.
R Notebooks provide a flexible interface for combining code chunks with descriptive text using Markdown. They allow users to run code interactively, view the output inline, and export polished reports in various formats (HTML, PDF, Word) with minimal effort.
By following this tutorial, you will learn the basics of R Notebooks, how to structure a notebook using Markdown, include and execute R code chunks, customise the output, and render your work as a fully reproducible document. These skills are essential for creating research outputs that are easy to understand, verify, and replicate.
The tutorial will also cover how R Notebooks differ from traditional R Markdown documents, how to track changes effectively, and how to use notebooks for collaborative writing and analysis. By adopting these practices, you foster openness and transparency in your research while improving your own workflow.
Creating R Notebooks
While many R users are familiar with R scripts and R Markdown, R Notebooks provide an ideal middle ground by enabling live execution, inline outputs, and seamless reporting. They are especially useful for iterative data exploration and producing well-documented, shareable code.
Creating an R Notebook in RStudio is simple. From the File menu, choose New File > R Notebook. This creates a document with the .Rmd extension and a YAML header specifying the notebook format. You can add narrative text using Markdown syntax and insert code chunks with R commands that execute inline.
The next sections will guide you through building your first notebook, using Markdown effectively, embedding plots and tables, and exporting your results as clean, formatted documents.
Markdown
Markdown is a lightweight markup language that you can use to add formatting elements to plaintext text documents. Markdown’s simplicity and readability render it attractive for a wide range of writing and documentation tasks. Its flexibility allows it to be extended to suit more complex needs, making it a versatile tool. Created by John Gruber in 2004, its primary purpose is to allow people to write in an easy-to-read and easy-to-write plain text format, which can then be converted to structurally valid HTML (or other formats such as docx or pdf). Markdown is widely used for documentation, web writing, and content creation because of its simplicity and flexibility. Markdown provides an authoring framework for data science as Markdown can produce high quality reports that can be shared with an audience. The advantage of Markdown is that you can use a single Markdown file (or Markdown document) to combine:
executable code
code output (such as visualisations and results of calculations)
plain text (to explain, report, and document)
R Markdown documents are fully reproducible and support dozens of static and dynamic output formats. Here are some key points about Markdown:
Simplicity: Markdown syntax is designed to be readable and easy to write. It avoids the complexity of other markup languages, making it accessible even for non-technical users.
Plain Text Formatting: Since Markdown is written in plain text, it can be created and edited in any text editor. This makes it highly portable and version control friendly.
Conversion: Markdown can be easily converted to HTML, making it ideal for web content. Many static site generators and content management systems support Markdown natively.
Extensibility: While the core syntax is intentionally simple, Markdown can be extended with plugins or additional syntaxes for more advanced features like tables, footnotes, and embedded content.
Common Uses of Markdown include, for example, documentation, read-me files, notes, and to-do lists, because it is easy to read in its raw form and can be rendered beautifully in web browsers.
These additional advanced Markdown features allow you to create even more complex and sophisticated documents. Practice using these commands to further enhance your Markdown proficiency!
Citation & Session Info
Schweinberger, Martin. 2025. Creating R Notebooks with Markdown. Brisbane: The University of Queensland. url: https://ladal.edu.au/tutorials/notebooks/notebooks.html (Version 2025.08.01).
@manual{schweinberger2025notebooks,
author = {Schweinberger, Martin},
title = {Creating R Notebooks with Markdown},
note = {tutorials/notebooks/notebooks.html},
year = {2025},
organization = {The University of Queensland, School of Languages and Cultures},
address = {Brisbane},
edition = {2025.08.01}
}