output_graph: Produce interactive or static graph output depending on...

View source: R/utils.R

output_graphR Documentation

Produce interactive or static graph output depending on environment

Description

output_graph For PDF output, we want high-resolution static vector graphics but for HTML output, sometimes we want the interactivity provided by the plotly library. Pass a ggplot2 object to this function, which will decide which output to produce.

Usage

output_graph(graph)

Arguments

graph

A ggplot2 graph object.

Details

Using plotly::ggplotly() adds interactive features to standard ggplot output (for example, tooltips can display information about individual data points). The HTML output produced by ggplotly() is, however, not valid if the destination output format for a report is either LaTeX or Word. This function checks the environment and routes a graph through ggplotly() if at the command prompt or when knitting an HTML document. If knitting to LaTeX or Word, then standard ggplot2 static output will be used (e.g. PDF or PNG).

Examples

## Not run: 
output_graph(p) # p is a ggplot object

## End(Not run)

nzbri/chchpd documentation built on July 6, 2023, 11:27 p.m.