Skip to contents

Captures the output of print() as a character string.

Usage

printToChar(x, collapse = "\n")

Arguments

x

[any]
Object to print

collapse

[character(1)]
Used to collapse multiple lines. NULL means no collapsing, vector is returned. Default is “\n”.

Value

[character].

Examples

x = data.frame(a = 1:2, b = 3:4)
str(printToChar(x))
#>  chr "  a b\n1 1 3\n2 2 4"