Re: [Rd] directing print.packageInfo to a file

From: Kurt Hornik <Kurt.Hornik_at_wu-wien.ac.at>
Date: Mon 02 Aug 2004 - 19:41:03 EST

>>>>> Gabor Grothendieck writes:

>
> I already suggested using the pager as a workaround
> in the original thread although your pager workaround
> has the advantage of being 100% in R while mine used
> a batch file which defined a new pager.
>
> Note that R already supports
>
> options(pager = "console")
>
> but if you do this then it seems that capture.output
> still won't capture it. Thus one alternative solution
> would be to get capture.output to work with
> pager = "console" and modify print.packageInfo to
> take a pager= argument which it would pass down to file.show.
> (file.show already has a pager argument.)
>
> Then one could write:
>
> capture.output( print.packageInfo(help(package = chron),
> pager = "console"), file = "myfile.txt")
>
> That gets it down to one line although it still seems
> unnecessarily indirect when one could just write:
>
> print.packageInfo(help(package = chron), file = "myfile.txt")
>
> if print.packageInfo just had a file= argument.
> Furthermore, print.packageInfo ALREADY creates the file as a
> temporary file to hand over to file.show so its not much of
> a stretch to give the user access to what it is already
> creating anyway.

The point about the proferred solution is that it works generally when is is desired to capture output that is "printed" via file.show(). If we start adding extra arguments to print.packageIQR (which is documented to be internal, btw), we would need to do the same for print.libraryIQR and print.hsearch and ..., i.e. for all print() methods which in fact display something using file.show() as a "side effect". That seems suboptimal to me, when one can wrap the above in a very simple and generally applicable function (and just calling the print() generic rather than some method, btw).

-k



R-devel@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-devel Received on Mon Aug 02 19:43:08 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:04 EST