Learn R Programming

dipsaus (version 0.3.1)

capture_expr: Captures Evaluation Output of Expressions as One Single String

Description

Evaluate expression and captures output as characters, then concatenate as one single string.

Usage

capture_expr(expr, collapse = "\n", type = c("output", "message"), ...)

Value

Character of length 1: output captured by capture.output

Arguments

expr

R expression

collapse

character to concatenate outputs

type, ...

passed to capture.output

Examples

Run this code

x <- data.frame(a=1:10)
x_str <- capture_expr({
  print(x)
})

x_str

cat(x_str)


Run the code above in your browser using DataLab