First day of class…
First day of class…
“Professor, I tried installing R but my laptop keeps running out of space.”
To your boss…
“I created this great dashboard, but IT is taking forever to approve the server request.”
With your colleague…
“Sorry, I don’t have R set up on my laptop.”
WebAssemby is a low-level, high-performance binary instruction format that allows code to run in web browsers.
Install the package:
Import the WebR class:
What if you don’t know JavaScript? 😅
---
title: "ggplot2 demo"
format:
html:
code-fold: true
---
## Meet Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
```{r}
#| label: plot-penguins
#| echo: false
#| message: false
#| warning: false
library(tidyverse)
library(palmerpenguins)
ggplot(penguins,
aes(x = flipper_length_mm, y = bill_length_mm)) +
geom_point(aes(color = species, shape = species)) +
scale_color_manual(values = c("darkorange","purple","cyan4")) +
labs(
title = "Flipper and bill length",
subtitle = "Dimensions for penguins at Palmer Station LTER",
x = "Flipper length (mm)", y = "Bill length (mm)",
color = "Penguin species", shape = "Penguin species"
) +
theme_minimal()
```
Scrollytelling extension
Journal of Statistical Software (JSS)
nes-revealjs format by EmilHvitfeldt
For example, there’s a fontawesome extension.
Install the extension:
Add to your Quarto document YAML heading:
Use the extension in the doc:
Results in:
Quarto extension gallery by Mickaël Canouil
Quarto Live embeds WebAssembly powered code blocks and exercises for R and Python into Quarto documents with HTML-based output formats.
Install the extension:
Add to your Quarto document YAML header:
Install the extension:
Add to your Quarto document YAML header:
webr
code chunk for Rpyodide
code chunk for PythonCan be used in presentations too:
live-revealjs
:quarto-drop
extension to drop an R or Python console into your slidesOptions include:
Designating a webr
chunk as an exercise (with optional setup code, hints, solutions, and grading).
Hint 1
Consider subtracting 1, 2, and 3 from 10.
Tip
The answer is 4 ☺️
Shiny allows you to create web apps, no web development skills required.
Some web services offer scalability, features, and cost:
But they can’t run traditional Shiny apps!
#| '!! shinylive warning !!': |
#| shinylive does not work in self-contained HTML documents.
#| Please set `embed-resources: false` in your metadata.
#| standalone: true
#| viewerHeight: 500
library(shiny)
library(bslib)
ui <- page_sidebar(
title = "Simple Shiny App",
theme = bs_theme(bootswatch = "flatly"),
sidebar = sidebar(
numericInput("number", "Enter a number:", value = 5, min = 1, max = 100),
selectInput("color", "Choose color:",
choices = c("red", "blue", "green", "purple"))
),
card(
card_header("Result"),
card_body(
plotOutput("plot")
)
)
)
server <- function(input, output) {
output$plot <- renderPlot({
plot(1:input$number,
col = input$color,
pch = 19,
cex = 2,
main = "Simple Plot",
xlab = "Index",
ylab = "Value")
})
}
shinyApp(ui, server)
Install the package:
Export the app:
Start a web server for the directory:
Install the Quarto extension:
Add to your Quarto document YAML heading:
Insert a code block with {shinylive-python}
or {shinylive-r}
bit.ly/interactive-data-science