capture.output

0th

Percentile

Send Output to a Character String or File

Evaluates its arguments with the output being returned as a character string or sent to a file. Related to sink in the same way that with is related to attach.

Keywords
utilities
Usage
capture.output(..., file = NULL, append = FALSE)
Arguments
...
Expressions to be evaluated.
file
A file name or a connection, or NULL to return the output as a character vector. If the connection is not open, it will be opened initially and closed on exit.
append
logical. If file a file name or unopened connection, append or overwrite?
Details

An attempt is made to write output as far as possible to file if there is an error in evaluating the expressions, but for file = NULL all output will be lost.

Value

A character string (if file = NULL), or invisible NULL.

See Also

sink, textConnection

Aliases
  • capture.output
Examples
library(utils) require(stats) glmout <- capture.output(example(glm)) glmout[1:5] capture.output(1+1, 2+2) capture.output({1+1; 2+2}) ## Not run: # ## on Unix with enscript available # ps <- pipe("enscript -o tempout.ps","w") # capture.output(example(glm), file = ps) # close(ps) # ## End(Not run)
Documentation reproduced from package utils, version 3.1.2, License: Part of R 3.1.2

Community examples

Looks like there are no examples yet.