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

From: Rolf Turner <r.turner_at_auckland.ac.nz>
Date: Thu, 01 May 2008 16:59:29 +1200

On 1/05/2008, at 4:40 PM, Johannes Hsing wrote:

> Tony Dell <anthony.dell@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?

        He'd get nothing at all.

        Did you ***try*** your code?

> And all this output

        ``All this output''! Consisting of the empty set !!!

> is redirected to your file by sink(), so it works
> as expected.

	That all depends on what you expect, I guess.  Most people
	would expect to get some output.  As Tony expected.

		cheers,

			Rolf Turner

######################################################################
Attention:
This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author.

This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.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. Received on Thu 01 May 2008 - 05:02:18 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 - 10:30:33 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