capture.output2: Capture output from a command

View source: R/base.R

capture.output2R Documentation

Capture output from a command

Description

Like classic capture.output(), but with additional arguments collapse and trim.

Usage

capture.output2(..., collapse = "\n", trim = FALSE)

Arguments

...

Arguments passed on to capture.output().

collapse

If TRUE, lines are collapsed into a single string. If FALSE, lines are returned as is. If any character, lines are collapsed using that character.

trim

If TRUE, leading and trailing whitespace from each line is removed before the lines are collapsed and/or returned.

Value

If collapse is TRUE or "\n", a character vector of length 1. Else, a character vector of length n, where n corresponds to the number of lines outputted by the expression passed to capture.output().

See Also

capture.output()

Examples

x <- capture.output2(str(list(a = 1, b = 2, c = 1:3)))
cat2(x)

toscm/toscutil documentation built on Feb. 23, 2025, 2:20 p.m.