knitFig: Easily knit a custom figure fragment

Description Usage Arguments Value Author(s) See Also Examples

View source: R/knitFig.R

Description

THis function was written to make it easy to knit figures with different, or dynamically generated, widths and heights (and captions) in the same chunk when working with R Markdown.

Usage

1
2
3
4
5
6
knitFig(plotToDraw,
        template = getOption("ufs.knitFig.template", NULL),
        figWidth = getOption("ufs.knitFig.figWidth", 16/2.54),
        figHeight = getOption("ufs.knitFig.figHeight", 16/2.54),
        figCaption = "A plot.",
        chunkName = NULL, ...)

Arguments

plotToDraw

The plot to draw, e.g. a ggplot plot.

template

A character value with the knit_expand template to use.

figWidth

The width to set for the figure (in inches).

figHeight

The height to set for the figure (in inches).

figCaption

The caption to set for the figure.

chunkName

Optionally, the name for the chunk. To avoid problems because multiple chunks have the name "unnamed-chunk-1", if no chunk name is provided, digest is used to generate an MD5-hash from Sys.time.

...

Any additional arguments are passed on to knit_expand.

Value

This function returns nothing, but uses knit_expand and knit to cat the result.

Author(s)

Gjalt-Jorn Peters

Maintainer: Gjalt-Jorn Peters <gjalt-jorn@userfriendlyscience.com>

See Also

knit_expand and knit

Examples

1
2
3
4
## Not run: 
knitFig(ggProportionPlot(mtcars$cyl))

## End(Not run)

userfriendlyscience documentation built on May 2, 2019, 1:09 p.m.