Interactive R Quick Reference Cheatsheet

Quick Reference Guide for Interactive R Coding with Quarto Live and WebR

Essential commands and examples for interactive R coding, plotting, widgets, and exercises using Quarto Live and WebAssembly.

Tools
Author
Affiliation
Published

March 22, 2025

Keywords

interactive R coding, R quick reference, ggplot interactive, Plotly interactive, interactive widgets

R Interactive Environment Setup

Install Quarto Live extension

quarto add r-wasm/quarto-live

YAML Configuration for interactive R

---
format: live-html
webr:
  packages:
    - dplyr
    - ggplot2
---

In-depth Tutorial: Installing Quarto Live & WebAssembly



Basic Interactive R Scripting

Example R code block:

```{webr}
# Basic interactive R script
x <- 1:10
mean(x)
```

Output:

In-depth Tutorial: Interactive R for Beginners

Interactive Plotting

ggplot2 Example

Source

```{webr}
library(ggplot2)
ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point()
```

Output

Plotly Example

Source

```{webr}
library(plotly)
plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, type = 'scatter', mode = 'markers')
```

Output

In-depth Tutorial: Interactive Data Visualization in R

Interactive Widgets & Exercises

Creating Interactive Widgets (htmlwidgets)

Source

```{webr}
library(DT)
DT::datatable(iris)
```

Output

Interactive Exercise with Hints and Solutions

Source

::: {.panel-tabset}

#### Exercise


```{webr}
#| exercise: ex_mean
# Calculate the mean of the following vector
vec <- c(2, 4, 6, 8, 10)
mean(vec)
```

#### Hint

Use the `mean()` function.

#### Solution

```r
mean(vec)
```
:::

Use the mean() function.

mean(vec)

In-depth Tutorial: Designing and Grading Interactive R Exercises

Further Reading


Back to top

Reuse

Citation

BibTeX citation:
@online{kassambara2025,
  author = {Kassambara, Alboukadel},
  title = {Interactive {R} {Quick} {Reference} {Cheatsheet}},
  date = {2025-03-22},
  url = {https://www.datanovia.com/learn/interactive/cheatsheets/interactive-r-quick-reference.html},
  langid = {en}
}
For attribution, please cite this work as:
Kassambara, Alboukadel. 2025. “Interactive R Quick Reference Cheatsheet.” March 22, 2025. https://www.datanovia.com/learn/interactive/cheatsheets/interactive-r-quick-reference.html.