Dear folks -- There are a number of functions -- I am thinking of str() as an example -- that produce text as a side-effect, rather then returning it. Is there any way to send the text produced by such functions into a character variable? Any suggestions would be greatly appreciated. andrewH -- View this message in context: http://r.789695.n4.nabble.com/Can-you-send-side-effect-text-into-a-variable-tp3746025p3746025.html Sent from the R help mailing list archive at Nabble.com.
Can you send "side effect" text into a variable?
2 messages · Andrew Hoerner, Baptiste Auguie
Hi,
Try this,
?capture.output
as in,
capture.output(cat("this is it"))
HTH,
baptiste
PS: Here's another example for fun,
# <begin absurd example>
library(textplot)
capture.output(txtplot(1:10))
library(gplots)
textplot(capture.output(txtplot(1:10)))
library(grid)
grid.cap()
# not sure how to get back to the original text from here..
# <end absurd example>
On 16 August 2011 12:28, andrewH <ahoerner at rprogress.org> wrote:
Dear folks -- There are a number of functions -- I am thinking of str() as an example -- that produce text as a side-effect, rather then returning it. Is there any way to send the text produced by such functions into a character variable? Any suggestions would be greatly appreciated. andrewH -- View this message in context: http://r.789695.n4.nabble.com/Can-you-send-side-effect-text-into-a-variable-tp3746025p3746025.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.