plotMD: Create plots for inclusion in RMarkdown reports

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Create plots for inclusion in RMarkdown reports

Usage

1
plotMD(fig, format = knitr::opts_current$get("fig_format"), envir = NULL)

Arguments

fig

A ggplot2 plot for processing.

format

A character vector of length one describing the desired output format.

envir

Environment to use to look for variables used in the plot. If NULL (the default), the environment embedded in fig is used.

Details

the envir argument should only be needed if local variables that are not part of the data argument are used in the plot and the plot is evaluated in an environment that differs from the environment where it was originally created. This happens when plotting figures that were created in a child document while use_namespace: true is in force.

Value

Depending on the value of format either a ggplot2 object (possibly the same as fig) or, if format = 'interactive' a plotly plot.

Author(s)

Peter Humburg

See Also

ggplotly

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
 library(ggplot2)
 library(plotly)
 fig <- ggplot(cars, aes(x=speed, y=dist)) + geom_point()
 plotMD(fig, format='s') ## uses ggplot2
 plotMD(fig, format='i') ## uses plotly


## End(Not run)

humburg/reportmd documentation built on May 17, 2019, 9:13 p.m.