Package 'rMosaic'

Title: R Bindings to the 'Mosaic' Visualization Framework
Description: Provides R bindings for 'Mosaic', a declarative grammar for linked, data-driven visualizations backed by 'DuckDB'. The package supplies 'htmlwidgets' and 'shiny' helpers for rendering 'Mosaic' specifications from R, including optional browser-side 'DuckDB-WASM' execution and selection export helpers for exploratory workflows.
Authors: Timur Rizvanov [aut, cre], Edward C. Ruiz [aut], Ruben Dries [aut, rev], Dries Lab [fnd] (Host laboratory and funding source), Boston University [fnd] (Undergraduate Research Opportunities Program (UROP))
Maintainer: Timur Rizvanov <[email protected]>
License: MIT + file LICENSE
Version: 0.1.3
Built: 2026-06-25 19:59:22 UTC
Source: https://github.com/cran/rMosaic

Help Index


Retrieve a stored Mosaic selection

Description

After pressing "Import Selection" in a runMosaicWithExport app, the selected data are stored inside the package under the name printed in the status bar (e.g. "mosaic_sel_1"). Use this function to retrieve a selection by that name.

Usage

get_mosaic_selection(name)

Arguments

name

Character scalar: the variable name returned by the import button (e.g. "mosaic_sel_1").

Value

The stored data.frame, or NULL with a warning if the name is not found.

See Also

list_mosaic_selections


List all stored Mosaic selections

Description

Returns the names of all selections currently held in the package store.

Usage

list_mosaic_selections()

Value

Character vector of selection names.

See Also

get_mosaic_selection


Render a Mosaic visualization in Shiny

Description

Renders a Mosaic visualization using the provided specification and data.

Usage

mosaic(
  spec,
  specType = c("auto", "json", "yaml", "esm"),
  data = NULL,
  backend = c("r", "wasm"),
  data_transport = c("auto", "file", "inline"),
  data_dir = NULL,
  width = NULL,
  height = NULL
)

Arguments

spec

JSON/YAML (as R list, text, or file) or ESM JS code (text or file).

specType

One of "auto" (default), "json", "yaml", or "esm".

data

Named list of data.frames to register in DuckDB.

backend

Database backend: "r" (default) for R DuckDB or "wasm" for browser WASM DuckDB.

data_transport

How 'backend = "wasm"' input tables are delivered to the browser. '"auto"' uses '"file"' when 'data_dir' is supplied and otherwise falls back to '"inline"' for portable widgets; '"inline"' keeps the row-JSON path; '"file"' writes Arrow IPC files to 'data_dir' and registers them in DuckDB-WASM by URL.

data_dir

Directory for '"file"' transport. Serve or save the widget from the same directory so relative URLs resolve.

width

CSS or pixel width (e.g. "100%", "600px", or numeric).

height

CSS or pixel height.

Value

An htmlwidget that renders the Mosaic visualization.


Shiny output for Mosaic widget

Description

Use this in the UI to create a placeholder for the Mosaic visualization.

Usage

mosaicOutput(outputId, width = "100%", height = "400px")

Arguments

outputId

output variable name

width, height

CSS dimensions (e.g. '100%', '400px') for the container.

Value

A Shiny UI output element for a Mosaic htmlwidget.


Shiny render function for Mosaic

Description

Use this in the server to render the Mosaic visualization to the output.

Usage

renderMosaic(expr, env = parent.frame(), quoted = FALSE)

Arguments

expr

An expression that generates a call to mosaic().

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

Value

A Shiny render function for use in a server output assignment.


Run a Mosaic Shiny App in the RStudio Viewer

Description

Launches a Shiny application displaying the Mosaic visualization.

Usage

runMosaicApp(
  spec,
  specType = c("auto", "json", "yaml", "esm"),
  data,
  backend = c("r", "wasm"),
  title = NULL,
  width = "100%",
  height = "600px"
)

Arguments

spec

JSON/YAML (as R list, text, or file) or ESM JS code (text or file).

specType

One of "auto" (default), "json", "yaml", or "esm".

data

Named list of data.frames to register in DuckDB.

backend

Database backend: "r" (default) for R DuckDB or "wasm" for browser WASM DuckDB.

title

Optional page title

width

CSS or pixel width (e.g. "100%", "600px", or numeric).

height

CSS or pixel height.

Value

A Shiny application object.


Run a Mosaic app and export brush/query selections back to R

Description

Runs a Mosaic app and allows exporting selections to R.

Usage

runMosaicExport(
  spec,
  specType = "auto",
  data,
  title = NULL,
  width = "100%",
  height = "600px",
  selection_env = NULL
)

Arguments

spec

JSON/YAML (as R list, text, or file) or ESM JS code (text or file).

specType

One of "auto" (default), "json", "yaml", or "esm".

data

Named list of data.frames to register in DuckDB.

title

Optional page title

width

CSS or pixel width (e.g. "100%", "600px", or numeric).

height

CSS or pixel height.

selection_env

where to store extracted selections

Value

A Shiny application object. When the user imports a selection, the selected rows are assigned into selection_env as mosaic_sel_<n>.


Run a Mosaic Shiny App with selection export

Description

Launches a Shiny application that allows selecting data points and exporting them to an R environment.

Usage

runMosaicWithExport(
  spec,
  specType = c("auto", "json", "yaml", "esm"),
  data,
  title = NULL,
  width = "100%",
  height = "600px",
  selection_env = NULL
)

Arguments

spec

JSON/YAML (as R list, text, or file) or ESM JS code (text or file).

specType

One of "auto" (default), "json", "yaml", or "esm".

data

Named list of data.frames to register in DuckDB.

title

Optional page title

width

CSS or pixel width (e.g. "100%", "600px", or numeric).

height

CSS or pixel height.

selection_env

Environment to store selections in

Value

A Shiny application object. When the user imports a selection, the selected rows are assigned into selection_env as mosaic_sel_<n>.