library(leaflet)
m <- leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
m # Print the mapQuarto example
HTMLWidgets
Leaflet
DataTable
library(DT)
library(dplyr)
penguins = read.csv("https://raw.githubusercontent.com/allisonhorst/palmerpenguins/master/inst/extdata/penguins.csv") %>%
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.
filtered = data.filter(function(penguin) {
return bill_length_min < penguin.bill_length_mm &&
islands.includes(penguin.island);
})Interestingly, previous code chunks can use variables created in future code chunks with ojs chunks since code is executed non-linearly.