print.ggvis: View in a ggvis plot in the browser.

View source: R/print.R

print.ggvisR Documentation

View in a ggvis plot in the browser.

Description

view_static creates a static web page in a temporary directory; view_dynamic generate a dynamic shiny app and launches it. print automatically picks between the two.

Usage

## S3 method for class 'ggvis'
print(x, dynamic = NA, launch = interactive(), ...)

view_static(x, plot_id = rand_id("plot_"), dest = NULL)

view_dynamic(x, plot_id = rand_id("plot_"), port = NULL, quiet = FALSE)

Arguments

x

A ggvis object.

dynamic

Uses view_dynamic if TRUE, view_static if FALSE. The default, NA, chooses automatically based on the presence of reactives or interactive inputs in x.

launch

If TRUE, will launch plot in a viewer/browser. If FALSE returns an object that you can print() to launch.

...

Other arguments passed on to view_dynamic and view_static ?from print.

plot_id

Unique identifier used to identify the plot on the page.

dest

Deprecated (this no longer works).

port

the port on which to start the shiny app. If NULL (the default), Shiny will select a random port.

quiet

If TRUE show status messages from Shiny. (Default is FALSE.)

Details

If view_static is used on a ggvis object that has dynamic components, it will output a static plot.

Examples

## Run these examples only in interactive R sessions
if (interactive()) {
# In most cases view_static is unnecessary; these will do the same thing:
mtcars %>% ggvis(~wt, ~mpg)
mtcars %>% ggvis(~wt, ~mpg) %>% view_static()

# Can find the output file with view_static() and html_print()
outfile <- mtcars %>% ggvis(~wt, ~mpg) %>%
  view_static() %>% htmltools::html_print(viewer = NULL)
}

ggvis documentation built on May 29, 2024, 1:12 a.m.