Movatterモバイル変換


[0]ホーム

URL:


capture.output {utils}R Documentation

Send Output to a Character String or File

Description

Evaluates its arguments with the output being returned as a characterstring or sent to a file. Related tosink similarly to howwith is related toattach.

Usage

capture.output(..., file = NULL, append = FALSE,               type = c("output", "message"), split = FALSE)

Arguments

...

Expressions to be evaluated.

file

A file name or aconnection, orNULL to returnthe output as a character vector. If the connection is not open,it will be opened initially and closed on exit.

append

logical. Iffile a file name or unopenedconnection, append or overwrite?

type,split

are passed tosink(), see there.

Details

It works viasink(<file connection>) and hence theR codeindots mustnot interfere with the connection (e.g., bycallingcloseAllConnections()).

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

Messages sent tostderr() (including those frommessage,warning andstop)are captured bytype = "message". Note that this can be“unsafe” and should only be used with care.

Value

A character string (iffile = NULL), or invisibleNULL.

See Also

sink,textConnection

Examples

require(stats)glmout <- capture.output(summary(glm(case ~ spontaneous+induced,                                     data = infert, family = binomial())))glmout[1:5]capture.output(1+1, 2+2)capture.output({1+1; 2+2})## Not run: ## on Unix-alike with a2ps availableop <- options(useFancyQuotes=FALSE)pdf <- pipe("a2ps -o - | ps2pdf - tempout.pdf", "w")capture.output(example(glm), file = pdf)close(pdf); options(op) ; system("evince tempout.pdf &")## End(Not run)

[Packageutils version 4.6.0Index]

[8]ページ先頭

©2009-2025 Movatter.jp