robservable (version 0.2.0)

robservable: Display an Observable notebook as HTML widget

Description

Display an Observable notebook as HTML widget

Usage

robservable(
  notebook,
  include = NULL,
  hide = NULL,
  input = NULL,
  observers = NULL,
  update_height = TRUE,
  update_width = TRUE,
  width = NULL,
  height = NULL,
  elementId = NULL
)

Arguments

notebook

The notebook id, such as "@d3/bar-chart", or the full notebook URL.

include

character vector of cell names to be rendered. If NULL, the whole notebook is rendered.

hide

character vector of cell names in include to be hidden in the output.

input

A named list of cells to be updated.

observers

A vector of character strings representing variables in observable that you would like to set as input values in Shiny.

update_height

if TRUE (default) and input$height is not defined, replace its value with the height of the widget root HTML element. Note there will not always be such a cell in every notebook. Set it to FALSE to always keep the notebook value.

update_width

if TRUE (default) and input$width is not defined, replace its value with the width of the widget root HTML element. Set it to FALSE to always keep the notebook or the Observable stdlib value.

width

htmlwidget width.

height

htmlwidget height.

elementId

optional manual widget HTML id.

Value

An object of class htmlwidget.

Details

If a data.frame is passed as a cell value in input, it will be converted into the format expected by d3 (ie, converted by rows)..

Examples

Run this code
# NOT RUN {
## Display a notebook cell
robservable(
  "@d3/bar-chart",
  include = "chart"
)

## Change cells data with input
robservable(
  "@d3/bar-chart",
  include = "chart",
  input = list(color = "red", height = 700)
)

## Change data frame cells data
df <- data.frame(table(mtcars$cyl))
names(df) <- c("name", "value")
robservable(
  "@d3/horizontal-bar-chart",
  include = "chart",
  input = list(data = df)
)

# }

Run the code above in your browser using DataCamp Workspace