capture(expression, collapse = "")
sprint(x,...)
- expression
{R expression whose output will be captured.}
- collapse
{Character used to join output lines. Defaults to
"\n". Use NULL
to return a vector of individual output lines.}
- x
{Object to be printed}
- ...
{Optional parameters to be passed to print
}
The capture
function uses sink
to capture the
printed results generated by expression
. The function sprint
uses capture
to redirect the
results of calling print
on an object to a string.
A character string, or if collapse==NULL
a vector of character
strings containing the printed output from the R expression.
WARNING {R 1.7.0+ includes capture.output
, which
duplicates the functionality of capture
. Thus, capture
is depreciated.}
[object Object]
texteval
,
capture.output
# capture the results of a loop
loop.text <- capture( for(i in 1:10) cat("i=",i,"") )
loop.text# put regression summary results into a string
data(iris)
reg <- lm( Sepal.Length ~ Species, data=iris )
summary.text <- sprint( summary(reg) )
cat(summary.text)
print
IO