capture.output2 {toscutil}R 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)

[Package toscutil version 2.7.4 Index]