Tools
Tools: Quartify: Transform Your R Scripts into Quarto Documentation in One Click
2026-01-26
0 views
admin
Introduction: The Challenge of Code Documentation ## What is quartify? ## The Problem quartify Solves ## Why quartify Stands Out ## 1. Frictionless Conversion ## 2. Respects Your Structure with RStudio Sections ## RStudio Section Syntax ## Hierarchy Example ## 3. From Script to Book in Seconds ## Installation ## From CRAN ## From GitHub (development version) ## Web Version - No Installation Required! ## Three Ways to Use quartify ## 1. Shiny Interface ## 2. RStudio Add-in ## 3. Command Line ## Complete Example ## Main Function: rtoqmd() ## Directory Conversion: rtoqmd_dir() ## Quarto Books ## Advanced Features ## Callouts ## Tabsets ## Mermaid Diagrams ## Functions ## Code Quality ## RStudio Snippets ## Best Practices ## 1. Structure Your Scripts with Sections ## 2. Write Narrative Comments ## 3. Use Metadata at the Beginning of Your Script ## Use Cases ## Resources ## Conclusion ## Try It Now! How many times have you written a brilliant R analysis, only to face the tedious task of converting it into a well-formatted report? If you're like most R users, you've probably spent hours copying and pasting code into Quarto documents, wrestling with chunk options, and reformatting comments. What if I told you there's a better way? Enter quartify – an R package that automatically transforms your existing R scripts into polished Quarto documents, without modifying a single line of your original code. quartify is an R package that bridges the gap between your analysis scripts and publication-ready documents. It converts R scripts (.R files) into Quarto documents (.qmd files). The philosophy of quartify: your code stays code, your comments become narrative text. Unlike other tools requiring special syntax, quartify works with your scripts exactly as they are. Important note: quartify is designed to create static documentation of your R script, not an executable notebook. The code displayed in the Quarto document is not executed: it's a visual representation of your script for documentation and sharing purposes. The goal: Keep your scripts clean and familiar while making them compatible with the Quarto ecosystem. Quartify works with regular R scripts. Your comments (#) naturally become narrative text, while your code blocks are intelligently organized. This is one of quartify's key features! If you use RStudio code sections, quartify automatically converts them into proper markdown headers. Important: Minimum 4 symbols at the end (#, = or -) Your navigation structure is preserved without any extra work! Need to convert an entire directory of scripts into a Quarto Book? Quartify handles multiple files easily, automatically assembling them into a coherent, navigable document structure. Try quartify immediately without installing anything: https://quartify.lab.sspcloud.fr/ Ideal for users who prefer a graphical interface. Perfect for an integrated RStudio workflow. Ideal for automation and CI/CD pipelines. Here's a simple R script analyzing the iris dataset: To convert this script: quartify automatically generates this structure from your R scripts! Highlight important information: 5 types available: callout-note, callout-tip, callout-warning, callout-caution, callout-important Organize content in interactive tabs: Embed diagrams directly: Integration with styler and lintr: After restarting RStudio, use: Quartify elegantly bridges the gap between exploratory code and polished documentation. It respects your workflow, preserves your structure, and eliminates the tedious reformatting. The next time you finish an R script and think "I should document this," remember: with quartify, you might have already done so without realizing it. For more information about quartify, visit the GitHub repository. Feel free to contribute or report issues! Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse COMMAND_BLOCK:
## Heading 2 #### ### Heading 3 ==== #### Heading 4 ---- Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
## Heading 2 #### ### Heading 3 ==== #### Heading 4 ---- COMMAND_BLOCK:
## Heading 2 #### ### Heading 3 ==== #### Heading 4 ---- COMMAND_BLOCK:
## Data Import #### ### Read CSV ==== #### Quality Check ---- ## Exploratory Analysis #### ### Descriptive Statistics ==== Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
## Data Import #### ### Read CSV ==== #### Quality Check ---- ## Exploratory Analysis #### ### Descriptive Statistics ==== COMMAND_BLOCK:
## Data Import #### ### Read CSV ==== #### Quality Check ---- ## Exploratory Analysis #### ### Descriptive Statistics ==== CODE_BLOCK:
install.packages("quartify")
library(quartify) Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
install.packages("quartify")
library(quartify) CODE_BLOCK:
install.packages("quartify")
library(quartify) CODE_BLOCK:
install.packages("devtools")
devtools::install_github("ddotta/quartify")
library(quartify) Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
install.packages("devtools")
devtools::install_github("ddotta/quartify")
library(quartify) CODE_BLOCK:
install.packages("devtools")
devtools::install_github("ddotta/quartify")
library(quartify) CODE_BLOCK:
library(quartify)
quartify_app() Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
library(quartify)
quartify_app() CODE_BLOCK:
library(quartify)
quartify_app() CODE_BLOCK:
library(quartify)
rtoqmd("my_script.R") Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
library(quartify)
rtoqmd("my_script.R") CODE_BLOCK:
library(quartify)
rtoqmd("my_script.R") COMMAND_BLOCK:
# Title : Iris Dataset Analysis
#
# Author : Your name
#
# Date : 2025-12-10
#
# Description : Exploring differences
# between iris species
# ## Data Exploration #### # Load necessary packages library(ggplot2)
library(dplyr) # This classic dataset contains iris flower measurements data("iris")
summary(iris) ## Visualization #### # Let's examine the relationship between petal length and width ggplot(iris, aes(x = Petal.Length, y = Petal.Width, color = Species)) + geom_point(size = 3, alpha = 0.7) + theme_minimal() + labs( title = "Iris Petal Dimensions by Species", x = "Petal Length (cm)", y = "Petal Width (cm)" ) ## Statistical Analysis #### # Calculate statistics by species iris %>% group_by(Species) %>% summarise( mean_petal_length = mean(Petal.Length), mean_petal_width = mean(Petal.Width), .groups = "drop" ) Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
# Title : Iris Dataset Analysis
#
# Author : Your name
#
# Date : 2025-12-10
#
# Description : Exploring differences
# between iris species
# ## Data Exploration #### # Load necessary packages library(ggplot2)
library(dplyr) # This classic dataset contains iris flower measurements data("iris")
summary(iris) ## Visualization #### # Let's examine the relationship between petal length and width ggplot(iris, aes(x = Petal.Length, y = Petal.Width, color = Species)) + geom_point(size = 3, alpha = 0.7) + theme_minimal() + labs( title = "Iris Petal Dimensions by Species", x = "Petal Length (cm)", y = "Petal Width (cm)" ) ## Statistical Analysis #### # Calculate statistics by species iris %>% group_by(Species) %>% summarise( mean_petal_length = mean(Petal.Length), mean_petal_width = mean(Petal.Width), .groups = "drop" ) COMMAND_BLOCK:
# Title : Iris Dataset Analysis
#
# Author : Your name
#
# Date : 2025-12-10
#
# Description : Exploring differences
# between iris species
# ## Data Exploration #### # Load necessary packages library(ggplot2)
library(dplyr) # This classic dataset contains iris flower measurements data("iris")
summary(iris) ## Visualization #### # Let's examine the relationship between petal length and width ggplot(iris, aes(x = Petal.Length, y = Petal.Width, color = Species)) + geom_point(size = 3, alpha = 0.7) + theme_minimal() + labs( title = "Iris Petal Dimensions by Species", x = "Petal Length (cm)", y = "Petal Width (cm)" ) ## Statistical Analysis #### # Calculate statistics by species iris %>% group_by(Species) %>% summarise( mean_petal_length = mean(Petal.Length), mean_petal_width = mean(Petal.Width), .groups = "drop" ) COMMAND_BLOCK:
library(quartify) # Simple conversion
rtoqmd("iris_analysis.R") # With immediate HTML rendering
rtoqmd("iris_analysis.R", render_html = TRUE, open_html = TRUE) Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
library(quartify) # Simple conversion
rtoqmd("iris_analysis.R") # With immediate HTML rendering
rtoqmd("iris_analysis.R", render_html = TRUE, open_html = TRUE) COMMAND_BLOCK:
library(quartify) # Simple conversion
rtoqmd("iris_analysis.R") # With immediate HTML rendering
rtoqmd("iris_analysis.R", render_html = TRUE, open_html = TRUE) COMMAND_BLOCK:
rtoqmd( input_file, # Source R file output_file = NULL, # Output .qmd file title = "My title", # Document title author = "Your name", # Author theme = "cosmo", # Quarto theme (25+ available) render_html = TRUE, # Generate HTML open_html = FALSE, # Open HTML automatically number_sections = TRUE, # Number sections show_source_line = TRUE # Show original line numbers
) Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
rtoqmd( input_file, # Source R file output_file = NULL, # Output .qmd file title = "My title", # Document title author = "Your name", # Author theme = "cosmo", # Quarto theme (25+ available) render_html = TRUE, # Generate HTML open_html = FALSE, # Open HTML automatically number_sections = TRUE, # Number sections show_source_line = TRUE # Show original line numbers
) COMMAND_BLOCK:
rtoqmd( input_file, # Source R file output_file = NULL, # Output .qmd file title = "My title", # Document title author = "Your name", # Author theme = "cosmo", # Quarto theme (25+ available) render_html = TRUE, # Generate HTML open_html = FALSE, # Open HTML automatically number_sections = TRUE, # Number sections show_source_line = TRUE # Show original line numbers
) COMMAND_BLOCK:
rtoqmd_dir( input_dir, # Directory containing .R files output_dir = NULL, # Output directory create_book = TRUE, # Create a Quarto Book author = "Your name", # Author render_html = FALSE # Generate HTML files
) Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
rtoqmd_dir( input_dir, # Directory containing .R files output_dir = NULL, # Output directory create_book = TRUE, # Create a Quarto Book author = "Your name", # Author render_html = FALSE # Generate HTML files
) COMMAND_BLOCK:
rtoqmd_dir( input_dir, # Directory containing .R files output_dir = NULL, # Output directory create_book = TRUE, # Create a Quarto Book author = "Your name", # Author render_html = FALSE # Generate HTML files
) COMMAND_BLOCK:
# Convert all .R files in a directory to a Quarto Book
rtoqmd_dir("scripts/analyses") # Generates:
# - One .qmd for each .R
# - A Quarto Book with navigation
# - HTML for each file Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
# Convert all .R files in a directory to a Quarto Book
rtoqmd_dir("scripts/analyses") # Generates:
# - One .qmd for each .R
# - A Quarto Book with navigation
# - HTML for each file COMMAND_BLOCK:
# Convert all .R files in a directory to a Quarto Book
rtoqmd_dir("scripts/analyses") # Generates:
# - One .qmd for each .R
# - A Quarto Book with navigation
# - HTML for each file COMMAND_BLOCK:
# callout-note - Callout Title
# Callout content on multiple lines.
# Each line starts with # Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
# callout-note - Callout Title
# Callout content on multiple lines.
# Each line starts with # COMMAND_BLOCK:
# callout-note - Callout Title
# Callout content on multiple lines.
# Each line starts with # COMMAND_BLOCK:
## Exploration des données #### # tabset # tab - Résumé
# Statistiques descriptives summary(iris) # tab - Structure
# Structure du dataset str(iris) # tab - Aperçu
# Premières lignes head(iris) Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
## Exploration des données #### # tabset # tab - Résumé
# Statistiques descriptives summary(iris) # tab - Structure
# Structure du dataset str(iris) # tab - Aperçu
# Premières lignes head(iris) COMMAND_BLOCK:
## Exploration des données #### # tabset # tab - Résumé
# Statistiques descriptives summary(iris) # tab - Structure
# Structure du dataset str(iris) # tab - Aperçu
# Premières lignes head(iris) COMMAND_BLOCK:
#| mermaid
#| eval: true
# gantt
# title Project planning
# dateFormat YYYY-MM-DD
# section Phase 1
# Data collection :2025-01-01, 30d
# Cleaning :2025-01-31, 20d
# section Phase 2
# Analysis :2025-02-20, 30d
# Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
#| mermaid
#| eval: true
# gantt
# title Project planning
# dateFormat YYYY-MM-DD
# section Phase 1
# Data collection :2025-01-01, 30d
# Cleaning :2025-01-31, 20d
# section Phase 2
# Analysis :2025-02-20, 30d
# COMMAND_BLOCK:
#| mermaid
#| eval: true
# gantt
# title Project planning
# dateFormat YYYY-MM-DD
# section Phase 1
# Data collection :2025-01-01, 30d
# Cleaning :2025-01-31, 20d
# section Phase 2
# Analysis :2025-02-20, 30d
# CODE_BLOCK:
#' Additionne deux nombres
#'
#' @param x Une valeur numérique
#' @param y Une valeur numérique
#' @return La somme de x et y
#' @examples
#' add_numbers(2, 3)
#' @export
add_numbers <- function(x, y) { return(x + y)
} Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
#' Additionne deux nombres
#'
#' @param x Une valeur numérique
#' @param y Une valeur numérique
#' @return La somme de x et y
#' @examples
#' add_numbers(2, 3)
#' @export
add_numbers <- function(x, y) { return(x + y)
} CODE_BLOCK:
#' Additionne deux nombres
#'
#' @param x Une valeur numérique
#' @param y Une valeur numérique
#' @return La somme de x et y
#' @examples
#' add_numbers(2, 3)
#' @export
add_numbers <- function(x, y) { return(x + y)
} COMMAND_BLOCK:
rtoqmd("script.R", use_styler = TRUE, use_lintr = TRUE) # Generates a tabset with:
# - "Original code"
# - "Formatted code" (styler suggestion)
# - "Issues" (lintr problems) Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
rtoqmd("script.R", use_styler = TRUE, use_lintr = TRUE) # Generates a tabset with:
# - "Original code"
# - "Formatted code" (styler suggestion)
# - "Issues" (lintr problems) COMMAND_BLOCK:
rtoqmd("script.R", use_styler = TRUE, use_lintr = TRUE) # Generates a tabset with:
# - "Original code"
# - "Formatted code" (styler suggestion)
# - "Issues" (lintr problems) CODE_BLOCK:
install_quartify_snippets() Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
install_quartify_snippets() CODE_BLOCK:
install_quartify_snippets() COMMAND_BLOCK:
## Introduction ####
## Analysis ####
## Results ####
## Conclusions #### Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
## Introduction ####
## Analysis ####
## Results ####
## Conclusions #### COMMAND_BLOCK:
## Introduction ####
## Analysis ####
## Results ####
## Conclusions #### COMMAND_BLOCK:
# We use a linear regression to examine
# the relationship between temperature and ice cream sales
model <- lm(sales ~ temperature, data = ice_cream_data) Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
# We use a linear regression to examine
# the relationship between temperature and ice cream sales
model <- lm(sales ~ temperature, data = ice_cream_data) COMMAND_BLOCK:
# We use a linear regression to examine
# the relationship between temperature and ice cream sales
model <- lm(sales ~ temperature, data = ice_cream_data) COMMAND_BLOCK:
# Title : Iris Data Analysis
#
# Author : Jane Doe
#
# Date : 2025-12-05
#
# Description : This analysis explores the differences
# between the three iris species.
# Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK:
# Title : Iris Data Analysis
#
# Author : Jane Doe
#
# Date : 2025-12-05
#
# Description : This analysis explores the differences
# between the three iris species.
# COMMAND_BLOCK:
# Title : Iris Data Analysis
#
# Author : Jane Doe
#
# Date : 2025-12-05
#
# Description : This analysis explores the differences
# between the three iris species.
# CODE_BLOCK:
install.packages("quartify")
library(quartify)
rtoqmd("your_script.R", render_html = TRUE) Enter fullscreen mode Exit fullscreen mode CODE_BLOCK:
install.packages("quartify")
library(quartify)
rtoqmd("your_script.R", render_html = TRUE) CODE_BLOCK:
install.packages("quartify")
library(quartify)
rtoqmd("your_script.R", render_html = TRUE) - 📝 R scripts with useful comments but hard to read for non-developers
- 👥 Difficult to share with non-technical colleagues
- 🔄 Duplication between code and documentation
- ⏰ Time wasted manually creating documentation - ✅ No R installation required
- ✅ Complete web interface
- ✅ All features available - Open an R script in RStudio
- Menu Addins → Convert R Script to Quarto - Convert your sections (## Data Exploration ####) into markdown headers
- Transform your comments into narrative text
- Organize your code into well-structured chunks
- Generate an elegant HTML with table of contents - 📖 Book structure: Chapters, parts, navigation
- 🗂️ Automatic sidebar: Navigation between all files
- 🔍 Integrated search: Search across the entire book
- 📱 Responsive design: Adapted for mobile/tablet/desktop - header + Tab: Metadata template
- callout + Tab: Callout template
- mermaid + Tab: Diagram template
- tabset + Tab: Tabset template - Technical documentation: Transform R scripts into navigable HTML documentation
- Code review: Facilitate reviews for teams
- Project management: Create Quarto Books for complex projects
- Teaching: Transform course scripts into accessible tutorials
- Reproducible research: Convert exploratory analyses into publication-ready supplements - 📦 GitHub: github.com/ddotta/quartify
- 📖 Documentation: ddotta.github.io/quartify
- 🌐 Web version: quartify.lab.sspcloud.fr
- 🎓 Getting Started: Getting Started Guide
- 💻 Presentation:
- 📚 Quarto docs: quarto.org
how-totutorialguidedev.toaimlgitgithub