cloudview

View htmlwidget objects over ssh connections, eg. with vscode-remote.

Installation

You can install the development version of cloudview from GitHub with:

# install.packages("devtools")
# devtools::install_github("anthonynorth/cloudview")
install.packages("cloudview", repos = c('https://anthonynorth.r-universe.dev', 'https://cloud.r-project.org'))

Usage

Cloudview can be used to explicitly serve a htmlwidget with cloudview(object), or you can setup cloudview to implicitly serve widgets on print(view = TRUE).

Serving htmlwidgets on print(view = TRUE) is achieved with enable_cloudview(). This function masks print.htmlwidget with a wrapper function that replaces the viewer() which is called when running R interactively (by default). Undo this operation with disable_cloudview().

Add enable_cloudview() to .Rprofile to always serve widgets on print(view = TRUE). Example from my dot-files:

# serve htmlwidgets with servr
local({
  has_cloudview <- "cloudview" %in% .packages(all.available = TRUE)
  is_ssh <- Sys.getenv("SSH_CONNECTION") != ""
  if (interactive() && is_ssh && has_cloudview) cloudview::enable_cloudview()
})