[R] capturing the result of print in a variable?

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Sep 10 22:30:42 CEST 2002


mmiller3 at iupui.edu (Michael A. Miller) writes:

> I'd like to capture the results of a print() command so that I
> can put the results in a tktext widget.  I know I can redirect
> the output to a file with sink.  I'm looking for something like
> that, but where I can redirect the output into a variable.  Is
> there a way to do that?

You can sink() to a textConnection. I might prefer just to use a
temporary file, though...

t<-textConnection("xxx","w")
sink(t)
ls("package:base")
sink()
library(tcltk)
tkpack(txt<-tktext(tt<-tktoplevel()))
tkinsert(txt, "end", (paste(xxx,"\n",collapse="")))


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list