Learn R Programming

svMisc (version 0.9-46)

captureAll: Run an R expression and capture output and messages in a similar way as it would be done at the command line

Description

This function captures results of evaluating an R expression the same way as it would be done in a R console. The result is in a character string. Errors, warnings and other consitions are treated as usual, including the delayed display of the warnings if options(warn = 0).

Usage

captureAll(expr)

Arguments

expr
A valid R expression to evaluate

Value

  • Returns a string with the result of the evaluation done in the user workspace.

See Also

Parse, clipsource

Examples

Run this code
writeLines(captureAll(1+1))
writeLines(captureAll(Parse("search()")))
  
writeLines(captureAll(Parse('1:2 + 1:3')))
writeLines(captureAll(Parse("badname")))

Run the code above in your browser using DataLab