knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

widgetdown

Travis build status

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")

Widgets in pkgdown sections

# set seed for reproducible widget id
if (requireNamespace("htmltools", quietly = TRUE)) {
  htmlwidgets::setWidgetIdSeed(42)
}

The package tests the use of htmlwidgets in pkgdown:

widgetdown tests several widgets available from RStudio.

leaflet

library(leaflet)
  leaflet() %>%
  addTiles() %>%
  addMarkers(
  lng=174.768,
  lat=-36.852,
  popup="The birthplace of R"
)

heatmaply

library(heatmaply)
heatmaply(mtcars, k_row = 3, k_col = 2)

plotly

library(plotly)
plot_ly(midwest,
  x = ~percollege,
  color = ~state,
  type = "box"
)

DiagrammeR

library(DiagrammeR)
grViz("
  digraph {
    layout = twopi
    node [shape = circle]
    A -> {B C D} 
  }")

Dygraphs

library(dygraphs)
dygraph(nhtemp, main = "New Haven Temperatures") %>% 
  dyRangeSelector(dateWindow = c("1920-01-01", "1960-01-01"))

networkD3

library(networkD3)
data(MisLinks, MisNodes)
forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
             Target = "target", Value = "value", NodeID = "name",
             Group = "group", opacity = 0.4)

rbokeh

library(rbokeh)
figure() %>%
  ly_points(Sepal.Length, Sepal.Width, data = iris,
    color = Species, glyph = Species,
    hover = list(Sepal.Length, Sepal.Width))

highcharter

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)


jayhesselberth/widgetdown documentation built on May 7, 2019, 8:43 a.m.