Quarto 101

Brian Cervantes Alvarez

What is Quarto?

Quarto allows you to

  • Present your findings in R, Python, Julia, & Observable

  • Use Revealjs (this presentation for example)

  • Have images, videos, and iframe backgrounds imbedded in your documents

“Publish reproducible, production quality articles, presentations, dashboards, websites, blogs, and books in HTML, PDF, MS Word, ePub, and more.” - quarto.org

Teaching with Quarto

# Set Parameters for Data Generation
set.seed(20242025)  # For reproducibility

classOverlap <- 0.2
proportionMajority <- 0.85
sampleSize <- 300
numericVariables <- 20
categoricalVariablePercentage <- 40
missingType <- 'none'
totalPercentageMissing <- 0

Teaching with Quarto

# Set Parameters for Data Generation
classOverlap <- 0.2
proportionMajority <- 0.85
sampleSize <- 300
numericVariables <- 20
categoricalVariablePercentage <- 40
missingType <- 'none'
totalPercentageMissing <- 0

# Generate and Store Simulated Datasets
datasetList <- list()  # Initialize list to store datasets

Teaching with Quarto

# Set Parameters for Data Generation
set.seed(20242025)  # For reproducibility

classOverlap <- 0.2
proportionMajority <- 0.85
sampleSize <- 300
numericVariables <- 20
categoricalVariablePercentage <- 40
missingType <- 'none'
totalPercentageMissing <- 0

# Generate and Store Simulated Datasets
datasetList <- list()  # Initialize list to store datasets

for (i in 1:5) {
  set.seed(100 + i)  # Different seed for each dataset to ensure variability
  
  # Generate datasets using the simtraindatfun function
  datasets <- simtraindatfun(
    classOverlap = classOverlap,
    proportionMajority = proportionMajority,
    sampleSize = sampleSize,
    numericVariables = numericVariables,
    categoricalVariablePercentage = categoricalVariablePercentage,
    missingType = missingType,
    totalPercentageMissing = totalPercentageMissing
  )
  
  # Store the generated datasets in the list with a unique name
  datasetList[[paste0("Dataset_", i)]] <- datasets
}

Use Tabsets in RevealJS/HTML

fizz_buzz <- function(fbnums = 1:50) {
  output <- dplyr::case_when(
    fbnums %% 15 == 0 ~ "FizzBuzz",
    fbnums %% 3 == 0 ~ "Fizz",
    fbnums %% 5 == 0 ~ "Buzz",
    TRUE ~ as.character(fbnums)
  )
  print(output)
}
def fizz_buzz(num):
  if num % 15 == 0:
    print("FizzBuzz")
  elif num % 5 == 0:
    print("Buzz")
  elif num % 3 == 0:
    print("Fizz")
  else:
    print(num)
function FizzBuzz(num)
  if num % 15 == 0
    println("FizzBuzz")
  elseif num % 5 == 0
    println("Buzz")
  elseif num % 3 == 0
    println("Fizz")
  else
    println(num)
  end
end
function fizzBuzz(num) {
  if (num % 15 === 0) {
    return "FizzBuzz";
  } else if (num % 5 === 0) {
    return "Buzz";
  } else if (num % 3 === 0) {
    return "Fizz";
  } else {
    return num;
  }
}

Shiny apps? No problem!

Shiny apps? No problem!

Serverless Shiny? Yep!

#| '!! shinylive warning !!': |
#|   shinylive does not work in self-contained HTML documents.
#|   Please set `embed-resources: false` in your metadata.
#| standalone: true
#| viewerHeight: 650
import matplotlib.pyplot as plt
import numpy as np
from shiny.express import ui, input, render

with ui.sidebar():
    ui.input_slider("n", "N", 0, 100, 20)


@render.plot(alt="A histogram")
def histogram():
    np.random.seed(19680801)
    x = 100 + 15 * np.random.randn(437)
    plt.hist(x, input.n(), density=True)

Wanna create a portfolio website?

Videos!

Wanna learn more?

Here are some pro tips before you jump into using quarto:

  • Understand how github works (push/pull/commits)
  • Learn and master how to use Rmarkdown
  • Understand how to create shiny/interactive applications
  • Then, jump into learning Quarto!

Wanna see everything that quarto’s got to offer? Click on the quarto logo!

Alt text

References

https://quarto.org/

https://quarto.org/docs/presentations/revealjs/

https://quarto.org/docs/presentations/revealjs/advanced.html

https://quarto.org/docs/authoring/markdown-basics.html