[Rd] Incomplete ouput with sink and split=TRUE e.g. with writeLines (PR#10713)

jo.irisson at gmail.com jo.irisson at gmail.com
Wed Feb 6 15:45:04 CET 2008


Full_Name: Jean-Olivier Irisson
Version: 2.6.1
OS: OS X 10.5.1, Linux FC 8
Submission from: (NULL) (194.167.139.32)


Example steps:

> sink("test1.txt")
> cat("foo\n")
> writeLines("bar\n")
> sink()
> sink("test2.txt", split=T)
> cat("foo\n")
foo
> writeLines("bar\n")
> sink()

And the content of the files are:

$ head test*
==> test1.txt <==
foo
bar


==> test2.txt <==
foo
bar

So all the output is correctly directed to the file connection but only some of
it is directed to the console (cat but not writeLines). This can be a problem
with writeLines but Duncan Murdoch on R-help stated that: "it is probably a sign
of a bigger problem in sink()".

Real life example:
> sink("test3.txt", split=T)
> t.test(runif(10),round(runif(10)*2))


data:  runif(10) and round(runif(10) * 2) 
alternative hypothesis: true difference in means is not equal to 0 
95 percent confidence interval:
 -0.9403446  0.2048443 
sample estimates:
mean of x mean of y 
0.5322499 0.9000000 

> sink()

$ head test3.txt 

	Welch Two Sample t-test

data:  runif(10) and round(runif(10) * 2) 
t = -1.3766, df = 14.103, p-value = 0.1901
alternative hypothesis: true difference in means is not equal to 0 
95 percent confidence interval:
 -0.9403446  0.2048443 
sample estimates:
mean of x mean of y 

Thank you in advance for your help.



More information about the R-devel mailing list