knitPrintListObjects {clinUtils}R Documentation

Include a list of objects in a knitr document

Description

Each object is included (internally) in a separated chunk, so different chunk options can be set for each object.

Usage

knitPrintListObjects(
  xList,
  generalLabel = "objectsList",
  labels = paste0(generalLabel, seq_along(xList)),
  titles = NULL,
  titleLevel = 2,
  printObject = FALSE,
  ...
)

Arguments

xList

List of objects to print.

generalLabel

String with general label for the chunks, used to build the labels. The labels are constructed as 'generalLabel[i]', with i the list index. Only use if labels is not specified.

labels

Character vector with labels, one for each chunk.
This is also used to define file names for plots exported in the document (e.g. via opts_chunk$set(dev = "png")).

titles

Character vector with section titles, one for each chunk.

titleLevel

Integer with level for section header, 1 for top-level section header.

printObject

Logical, if TRUE (FALSE by default), each object within xList is explicitely printed with the print function.

...

any knitr chunk parameters (excepted 'results', set to 'asis' and 'echo' set to FALSE internally).
See knitr[opts_chunk] for further details on available options. Each parameter can be specified for each element in the list separately: by specifying a vector with the same length than the list; or for all elements at once: by specifying a vector of length 1 (in this case it will be replicated).

Details

This function should be called within a chunk with the following option: results = 'asis'.

Value

No returned value, a text is printed with chunk content

Author(s)

Laure Cougnaud

Examples

## Not run: 
	
# Note: the following code should be included 
# within a chunk of a knitr (e.g. RMarkdown) document
# to include a list of objects in the Rmarkdown output

# list of flextable objects
library(flextable)
listTables <- list(flextable(iris), flextable(cars))
knitPrintListObjects(
	xList = listTables,
	titles = c("Iris dataset", "Cars dataset")
)


## End(Not run)

[Package clinUtils version 0.1.5 Index]