Re: [R] sink() within a loop

From: <jgarcia_at_ija.csic.es>
Date: Wed, 05 Nov 2008 19:19:10 +0100 (CET)

Well, I'll put a foo example of my problem:

I'got a list:

>a <- list()
>a$sublist.1 <- list()
>a$sublist.1$subsublist.1 <- list()

this code works:

>zz <- file("foo.txt","w")
>sink(zz)
>a
>sink()
>close(zz)

and generates a correct "foo.txt" file containing the structure of the list

but this code doesn't:

>for(i in 1){

 zz <- file("foo.txt","w")
 sink(zz)
 a
 sink()
 close(zz)
}

as the resulting "foo.txt" file is empty

I don't understand why.

Javier


>
>
> jgarcia@ija.csic.es wrote:
>> Hello;
>> It seems to me that this could even by a FAQ, but I cannot find an
>> answer:
>>
>> Why a piece of code that uses sink() does not sinks anything if it is
>> executed within a for loop?
>
> Without sink(), does it print anything in the console? If not: use
> print() in order to print it (i.e. sink it to another connection).
>
> Uwe Ligges
>
>
>>
>>
>> Thanks,
>> Javier
>>
>> ______________________________________________
>> 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.
>



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 Wed 05 Nov 2008 - 18:21:47 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 Wed 05 Nov 2008 - 19:30:44 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