library(leaflet)
<- leaflet() %>%
m addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
# Print the map m
Quarto example
HTMLWidgets
Leaflet
DataTable
library(DT)
library(dplyr)
= read.csv("https://raw.githubusercontent.com/allisonhorst/palmerpenguins/master/inst/extdata/penguins.csv") %>%
penguins mutate(species = as.factor(species),
island = as.factor(island),
sex = as.factor(sex))
datatable(penguins, filter = "top")
ObservableJS
This piece of code implements the data filtering based on the input selectors below. bill_length_min
(slider) and islands
(checkboxes) are inputs initialized in the code chunk after this one.
= data.filter(function(penguin) {
filtered return bill_length_min < penguin.bill_length_mm &&
.includes(penguin.island);
islands })
Interestingly, previous code chunks can use variables created in future code chunks with ojs
chunks since code is executed non-linearly.