md_figure {simplermarkdown}R Documentation

Generate a figure and generate the markdown to include the figure

Description

Will evaluate the expressions in expr and capture the output on the given plotting device in the given file. It will then generate the markdown needed to include that figure in a markdown document.

Usage

md_figure(
  expr,
  name,
  caption = "",
  id = "",
  dir = file.path(Sys.getenv("MDOUTDIR", "."), "figures"),
  device = c("png", "pdf"),
  ...,
  as_character = FALSE,
  echo = FALSE,
  results = FALSE,
  formatter = getOption("md_formatter", default = format_traditional),
  capture_warnings = FALSE,
  capture_messages = results,
  muffle_warnings = FALSE,
  muffle_messages = TRUE
)

Arguments

expr

the expressions to evaluate. Will generally contain plotting commands. The expressions are evaluated in the global environment.

name

the name of the figure.

caption

text of the caption. When omitted no caption is added to the figure.

id

id of the figure. When omitted or equal to NULL or an empty character, no id is added to the figure.

dir

name of the directory in which to store the file.

device

the graphics device to use for creating the image.

...

passed on to the graphics device.

as_character

return the figure as a character vector. If FALSE the figure will be written to the standard output.

echo

the code in code is repeated in the output.

results

include the results of running the code in the output. The output of code that explicitly writes to standard output is always included.

formatter

function that will format the R-code and resulting output (if requested). See format_traditional for possible options.

capture_warnings

include warnings in the output.

capture_messages

include messages in the output.

muffle_warnings

do not show warnings in the console.

muffle_messages

do not show messages in the console.

Details

The image is stored in the file dir/name.device.

Value

When as_character = FALSE a character vector with the markdown needed to include the generated figure in a markdown file is returned. Otherwise, nothing is returned; the markdown is written to the console.


[Package simplermarkdown version 0.0.6 Index]