\HeaderA{capture.output}{Send output to a character string or file}{capture.output}
\keyword{utilities}{capture.output}
\begin{Description}\relax
Evaluates its arguments with the output being returned as a character
string or sent to a file. Related to \code{\LinkA{sink}{sink}} in the same
way that \code{\LinkA{with}{with}} is related to \code{\LinkA{attach}{attach}}.
\end{Description}
\begin{Usage}
\begin{verbatim}
capture.output(..., file = NULL, append = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{...}] Expressions to be evaluated
\item[\code{file}] A file name or a connection, or \code{NULL} to return
the output as a string. If the connection is not open it will be
opened and then closed on exit.
\item[\code{append}] Append or overwrite the file? 
\end{ldescription}
\end{Arguments}
\begin{Value}
A character string, or \code{NULL} if a \code{file} argument was
supplied.
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{sink}{sink}}, \code{\LinkA{textConnection}{textConnection}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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)
\end{ExampleCode}
\end{Examples}

