tpl_plot_figure: Returns a character vector for the code chunk to plot a...

View source: R/chunk_templates.R

tpl_plot_figureR Documentation

Returns a character vector for the code chunk to plot a figure

Description

Returns a character vector for the code chunk to plot a figure

Usage

tpl_plot_figure(
  chunk_label,
  figure_caption,
  figure_height,
  font_family = get_font_df()[["family"]],
  function_call = "RUBer::plot_figure",
  tab_placeholder = "PLACEHOLDER_TAB",
  suppress_warnings = FALSE
)

Arguments

chunk_label

Character, chunk label

figure_caption

Character, figure caption

figure_height

Numeric, figure height in inches

font_family

Character, the font family to use for all plots, defaults to get_font_df()[["family"]]

function_call

Character, defaults to RUBer::plot_figure

tab_placeholder

Character, pandoc does not support the insertion of tabs, which is why a placeholder text is needed that will get replaced with tabs in post-processing, defaults to "PLACEHOLDER_TAB"

suppress_warnings

Boolean, whether to suppress the warnings generated by this code chunk, defaults to FALSE.

Value

List of character vectors with chunk texts

Examples

# Returns code chunk as list
code_chunk_list <- tpl_plot_figure(
  chunk_label = 1L,
  figure_caption = "Caption for figure 1",
  figure_height = 4.2
)

# Unlist
code_chunk_vector <- unlist(
  code_chunk_list
)

# Display code chunks as they will be written to the Rmd
writeLines(
  code_chunk_vector
)

# The function is vectorized, so you can do this:
tpl_plot_figure(
  chunk_label = c(
    1L,
    2L
  ),
  figure_caption = c(
    "Caption for figure 1",
    "Caption for figure 2"
  ),
  figure_height = c(
    4.2,
    3.5
  )
)

RichardMeyer-Eppler/RUBer documentation built on June 2, 2022, 7:24 p.m.