printToChar: Prints object to a string / character vector

View source: R/printToChar.R

printToCharR Documentation

Prints object to a string / character vector

Description

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

BBmisc documentation built on Nov. 6, 2026, 1:06 a.m.