knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
# set seed for reproducible widget id if (requireNamespace("htmltools", quietly = TRUE)) { htmlwidgets::setWidgetIdSeed(42) }
htmlwidgets in pkgdown sites need special treatment for some site components.
If you include widgets in a README.Rmd
, add always_allow_html: yes
to the YAML front matter. You'll get a error if you try to knit the document without that option.
If you include widgets in your vignettes, use chunk option out.width = '100%'
to ensure the widget spans the entire container.
library(leaflet) leaflet() %>% addTiles() %>% addMarkers( lng=174.768, lat=-36.852, popup="The birthplace of R" )
library(heatmaply) heatmaply(mtcars, k_row = 3, k_col = 2)
library(plotly) plot_ly(midwest, x = ~percollege, color = ~state, type = "box" )
library(DiagrammeR) grViz(" digraph { layout = twopi node [shape = circle] A -> {B C D} }")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.