robservable {robservable}R Documentation

Display an Observable notebook as HTML widget

Description

Display an Observable notebook as HTML widget

Usage

robservable(
  notebook,
  include = NULL,
  hide = NULL,
  input = NULL,
  input_js = NULL,
  observers = NULL,
  update_height = TRUE,
  update_width = TRUE,
  width = NULL,
  height = NULL,
  elementId = NULL,
  json_args = list(dataframe = "rows"),
  json_func = 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 with a fixed value.

input_js

A named list of cells to be updated with JavaScript code. Each list element is itself a list with a vector of argument names as inputs entry, and a character string of JavaScript code as definition entry, as expected by Observable runtime variable.define function.

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.

json_args

custom arguments passed to JSON serializer.

json_func

optional custom JSON serializer R function.

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

For more details on the use of input_js to update cells with JavaScript code, see the introduction vignette and https://github.com/observablehq/runtime#variable_define.

Value

An object of class htmlwidget.

Examples

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


[Package robservable version 0.2.2 Index]