Chapter 30

Quarto Formats

Author

Aditya Dahiya

Published

July 25, 2023

30.5 Interactivity

library(DT)
library(tidyverse)
library(knitr)

30.5.1. htmlwidgets

Let us try to create an interactive map in HTML below Figure 1:—̥

library(leaflet)
leaflet() |>
  setView(76.801175, 30.761403, zoom = 14) |> 
  addTiles() |>
  addMarkers(76.801175, 30.761403, 
             popup = "Haryana Civil Secretariat")  |>
  addMarkers(76.803773534,
             30.752910586,
             popup = "Rock Garden")
Figure 1: A map of Chandigarh, India using Leaflet

Using DT for interactive tables:---

An example of using DT for an interactive table is at Figure 2 :---

diamonds |>
  filter(carat > 3) |>
  datatable(colnames = c("Carat", "Cut", "Color",
                         "Clarity", "Depth", "Table",
                         "Price", "X", "Y", "Z"),
            rownames = FALSE)
Figure 2: A visually pleasing table produced using DT package