[R] Incomplete ouput with sink and split=TRUE

Alex Brown fishtank at compsoc.man.ac.uk
Wed Feb 6 11:25:45 CET 2008


you could use the unix function 'script' before invoking the R  
interpreter.

example session:

$ script
Script started, file is typescript
[x86_64|alex at riki:~]
$ R --quiet --vanilla
 > 1:10
[1]  1  2  3  4  5  6  7  8  9 10
 > q()
[x86_64|alex at riki:~]
$ exit
exit
Script done, file is typescript


contents of file typescript:

===========
Script started on Tue Feb  5 19:01:32 2008
[x86_64|alex at riki:~]
$ R --quiet --vanilla
 > 1:10
[1]  1  2  3  4  5  6  7  8  9 10
 > q()
[x86_64|alex at riki:~]
$ exit
exit

Script done on Tue Feb  5 19:01:45 2008
[x86_64|alex at riki:~]
============

-Alex

On 5 Feb 2008, at 16:12, jiho wrote:

> Dear List,
>
> I am trying to get R's terminal output to a file and to the terminal
> at the same time, so that I can walk through some tests and keep a log
> concurrently. The function 'sink' with the option split=TRUE seems to
> do just that. It works fine for most output but for objects of class
> htest, the terminal output is incomplete (the lines are there but
> empty). Here is an example session which shows the problem:
>
>> sink("textout.txt", type="output", split=T)
>> b=bartlett.test(runif(10),c(1,1,1,1,2,2,2,2,2,2))
>> class(b)
> [1] "htest"
>> b
>
>
> data:  runif(10) and c(1, 1, 1, 1, 2, 2, 2, 2, 2, 2)
>
>> t=t.test(runif(10),c(1,1,1,1,2,2,2,2,2,2))
>> t
>
>
> data:  runif(10) and c(1, 1, 1, 1, 2, 2, 2, 2, 2, 2)
> alternative hypothesis: true difference in means is not equal to 0
> 95 percent confidence interval:
> -1.5807338 -0.7316803
> sample estimates:
> mean of x mean of y
> 0.4437929 1.6000000
>
>> sink()	# output in the file is complete
>> b
>
> 	Bartlett test of homogeneity of variances
>
> data:  runif(10) and c(1, 1, 1, 1, 2, 2, 2, 2, 2, 2)
> Bartlett's K-squared = 0.9959, df = 1, p-value = 0.3183
>
>> t
>
> 	Welch Two Sample t-test
>
> data:  runif(10) and c(1, 1, 1, 1, 2, 2, 2, 2, 2, 2)
> t = -5.7659, df = 16.267, p-value = 2.712e-05
> alternative hypothesis: true difference in means is not equal to 0
> 95 percent confidence interval:
> -1.5807338 -0.7316803
> sample estimates:
> mean of x mean of y
> 0.4437929 1.6000000
>
>>
>
> Is this a known bug (I'm using R 2.6.1 on OS X and Linux - FC8)? Is
> there an inherent reason why some portions of this output are not
> redirected?
>
> Thank you in advance for your help.
>
> JiHO
> ---
> http://jo.irisson.free.fr/
>
> ______________________________________________
> 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.



More information about the R-help mailing list