[R] putting output from print() into a string?

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Sun Nov 12 16:46:46 CET 2000


Uwe Ligges <ligges at statistik.uni-dortmund.de> writes:

> On Sun, 12 Nov 2000, David Firth wrote:
> 
> > Is there some neat way of storing the printed representation of an 
> > object as a character string?  I can see how it could be done via 
> > disk using sink() and then scan(), but that's ugly.
> > 
> > Something like Lisp-Stat's "with-output-to-string" macro perhaps?
> 
> dump() ?

I don't think that was what David was looking for. If you really want
to postprocess the printed output, the sink-then-scan method would
seem to be the way to do it (or the soon-to- be readLines() instead of
scan()). I suppose that a sink(text=...) could be implemented, but
AFAIK it is not on anyones TODO list. 

One obvious counterquestion is "Why?". It would normally be preferable
to retrieve information from the object itself rather than the printed
representation, which is generally lossful in a number of ways. 

-- 
   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