Learn R Programming

toscutil (version 2.8.0)

capture.output2: Capture output from a command

Description

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

Usage

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

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().

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.

See Also

Examples

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

Run the code above in your browser using DataLab