dput2 {toscutil}R Documentation

Return ASCII representation of an R object

Description

Like classic dput(), but instead of writing to stdout, the text representation is returned as string.

Usage

dput2(..., collapse = " ", trim = TRUE)

Arguments

...

Arguments passed on to dput().

collapse

Character to use for collapsing the lines.

trim

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

Value

If collapse == '\n', a character vector of length 1. Else, a character vector of length n, where n corresponds to the number of lines outputted by classic dput().

See Also

dput()

Examples

# Classic dput prints directly to stdout
x <- iris[1,]
dput(x)

# Traditional formatting using dput2
y <- dput2(x, collapse = "\n", trim = FALSE)
cat2(y)

# Single line formatting
z <- dput2(x)
cat2(z)

[Package toscutil version 2.7.4 Index]