knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of widgetdown is to test the use of htmlwidgets in a pkgdown website, without bloating the pkgdown package itself.
Install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("jayhesselberth/widgetdown")
# set seed for reproducible widget id if (requireNamespace("htmltools", quietly = TRUE)) { htmlwidgets::setWidgetIdSeed(42) }
The package tests the use of htmlwidgets in pkgdown:
README.Rmd
or index.Rmd
)@examples
.widgetdown tests several widgets available from RStudio.
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} }")
library(dygraphs) dygraph(nhtemp, main = "New Haven Temperatures") %>% dyRangeSelector(dateWindow = c("1920-01-01", "1960-01-01"))
library(networkD3) data(MisLinks, MisNodes) forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.4)
library(rbokeh) figure() %>% ly_points(Sepal.Length, Sepal.Width, data = iris, color = Species, glyph = Species, hover = list(Sepal.Length, Sepal.Width))
library(magrittr) library(highcharter) highchart() %>% hc_title(text = "Scatter chart with size and color") %>% hc_add_series_scatter(mtcars$wt, mtcars$mpg, mtcars$drat, mtcars$hp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.