Re: [R] using the sink() function in a for-look

From: Johannes Hüsing <johannes_at_huesing.name>
Date: Thu, 01 May 2008 06:40:25 +0200

Tony Dell <anthony.dell_at_jcu.edu.au> [Thu, May 01, 2008 at 04:32:23AM CEST]:
> hi all,
>
> i wanted to use the sink function to sequentially output regression
> summaries within a for-loop. i must have something wrong somewhere (or be
> using the sink function incorrectly), but can anyone help?
>
> the code I am using is:
>

Please use code and data which is reproducible for us. As we don't have access to your data, we'd have to construct some of our own.

This code, however, has the same effect:

for (i in 1:100) {

    sink("./sometext.txt", append=TRUE)
    summary(rnorm(80))
    sink()}

When you do the following:

for (i in 1:100) {

    summary(rnorm(80))}

what output do you get?

And all this output is redirected to your file by sink(), so it works as expected.

-- 
Johannes Hüsing               There is something fascinating about science. 
                              One gets such wholesale returns of conjecture 
mailto:johannes_at_huesing.name  from such a trifling investment of fact.                
http://derwisch.wikidot.com         (Mark Twain, "Life on the Mississippi")

______________________________________________
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.
Received on Thu 01 May 2008 - 04:42:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 01 May 2008 - 05:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive