Interactive Coding Overview
- Interactive Coding: Execute code blocks interactively in Quarto documents.
- Engines Supported:
webr
(R) andpyodide
(Python). - Key Benefits: Immediate feedback, dynamic visualizations, seamless integration of R and Python.
Learn more in the Introduction to Interactive Coding.
Installing Quarto Live & WebAssembly
Install Quarto Live extension:
quarto add r-wasm/quarto-live
Configure YAML header:
---
format: live-html
---
Detailed instructions in Installing Quarto Live & WebAssembly Engines.
Creating and Managing Interactive Code Blocks
Basic interactive code block example
Source:
```{webr}
print("Hello, Interactive World!")
```
```{pyodide}
print("Hello, Interactive World!")
```
Output:
Explore further in Interactive Code Blocks Explained.
Useful Cell Options:
Option | Description | Default |
---|---|---|
autorun |
Automatically executes code on page load. | false |
edit |
Allows editing of code blocks. | true |
runbutton |
Shows “Run Code” button. | true |
completion |
Enables autocomplete suggestions. | true |
startover |
Shows “Start Over” button. | true |
persist |
Persists user modifications. | false |
timelimit |
Time limit for code execution (seconds). | 30 |
include |
Display code block output and source. | true |
min-lines |
Minimum visible lines in editor. | 0 |
max-lines |
Maximum visible lines in editor. | ∞ |
Example usage:
```{webr}
#| autorun: true
#| edit: false
summary(cars)
```
```{pyodide}
#| autorun: true
#| edit: false
import numpy as np
np.mean([1, 2, 3, 4, 5])
```
Environment Management and Variable Sharing
Define global setup code:
Execute code globally before other interactive blocks:
```{webr}
#| setup: true
data(iris)
```
```{pyodide}
#| setup: true
import numpy as np
```
Further Reading
Explore More Articles
Here are more articles from the same category to help you dive deeper into the topic.
Reuse
Citation
@online{kassambara2025,
author = {Kassambara, Alboukadel},
title = {Interactive {Coding} {Essentials} {Cheatsheet}},
date = {2025-03-22},
url = {https://www.datanovia.com/learn/interactive/cheatsheets/interactive-coding-essentials.html},
langid = {en}
}