The filename argument may be given with an sprintf() format including
"%d" to allow automatic numbering of the output filenames. Specifically, the
pattern of "%d" with an optional non-negative integer between the "%" and "d"
is searched for and if found, then the filename will be generated using that
sprintf() format. Note that also means that other requirements for
sprintf() must be met; for example, if you want a percent sign ("%") in the
filename, it must be doubled so that sprintf returns what is desired.
Usage
# S3 method for class 'gglist'
knit_print(
x,
...,
filename = NULL,
fig_suffix = NULL,
float_barrier_after = 10
)
# S3 method for class 'ggtibble'
knit_print(x, ...)Arguments
- x
The gglist object
- ...
extra arguments to
knit_print()- filename
A filename with an optional "%d" sprintf pattern for saving the plots
- fig_suffix
Any text to add after the figure. Defaults to
NULL, which means "auto-select":"\n\n\\FloatBarrier\n\n"for LaTeX output whenlength(x) > float_barrier_after, otherwise"\n\n".- float_barrier_after
Numeric threshold for emitting
\FloatBarrierbetween figures in LaTeX output. Whenlength(x) > float_barrier_afterandknitr::is_latex_output()isTRUEand the user did not supplyfig_suffix,fig_suffixdefaults to"\n\n\\FloatBarrier\n\n". Has no effect on non-LaTeX output. Set toInfto disable. Defaults to10.
Details
When length(x) exceeds float_barrier_after and the output format is
LaTeX (as detected by knitr::is_latex_output()), fig_suffix defaults to
"\n\n\\FloatBarrier\n\n" instead of the usual "\n\n". This avoids the
LaTeX "Output loop—100 consecutive dead cycles" error that occurs when
the float queue (default capacity ~18) overflows. \FloatBarrier is
provided by the placeins LaTeX package, which is not loaded by default
in rmarkdown::pdf_document; add \usepackage{placeins} to the document
preamble (e.g. via header-includes in the YAML) when relying on the
auto-suffix. Pass fig_suffix explicitly to override, or set
float_barrier_after = Inf to disable the auto-suffix entirely.
See also
Other knitters:
knit_print.gg()
Examples
# Ensure that each figure is within its own float area
mydata <-
list(
data.frame(x = 1:3, y = 3:1),
data.frame(x = 4:7, y = 7:4)
)
p <- gglist(mydata, ggplot2::aes(x = x, y = y)) +
ggplot2::geom_point()
knit_print(p, fig_suffix = "\n\n\\FloatBarrier\n\n")
#>
#>
#>
#>
#> \FloatBarrier
#>
#>
#>
#>
#>
#>
#>
#> \FloatBarrier
#>
#>
#>