Level-two and below headings…
…are all contained in the same section.
Example text.
You may include any number of plots in a section.
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.3
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(maps)
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.3.3
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# 1. Texas map
tx_map <- map_data("state") %>% filter(region == "texas")
# 2. Fake road routes (as lines)
# Let's create 3 fake roads
roads <- list(
data.frame(x = c(-100, -95, -90), y = c(31, 32, 33), road = "Road A"),
data.frame(x = c(-98, -96, -94), y = c(29, 30, 31), road = "Road B"),
data.frame(x = c(-97, -95, -93), y = c(32, 33, 34), road = "Road C")
)
# 3. Base Texas polygon
p <- plot_ly() %>%
add_trace(
data = tx_map,
x = ~long, y = ~lat, type = 'scatter', mode = 'lines',
split = ~group, line = list(color = 'black'),
name = 'Texas'
)
# 4. Add fake roads
for (r in roads) {
p <- add_trace(
p,
data = r,
x = ~x, y = ~y,
type = 'scatter', mode = 'lines+markers',
line = list(width = 3),
marker = list(size = 6),
name = ~r$road[1],
text = ~r$road, # tooltip on hover
hoverinfo = 'text'
)
}
# 5. Layout
p <- layout(p,
title = "Texas with Clickable Fake Roads",
yaxis = list(scaleanchor = "x", title = ""),
xaxis = list(title = "")
)
p
Local news reported a giant inflatable rubber duck rolling down the street of Des Moines, where this package is conceived.
You should call rolldown::scrollama_setup()
at the end of a document. Turn off the debug
option to get rid of the horizontal line on the page, and you probably also want echo=FALSE
on this code chunk:
rolldown::scrollama_setup(
list(step = '.level1', offset = .2, debug = TRUE)
)