[R] [R-SIG-Mac] txtStart creates a NULL file

Simon Urbanek simon.urbanek at r-project.org
Wed Feb 15 04:02:05 CET 2012


On Feb 14, 2012, at 8:31 PM, R. Michael Weylandt wrote:

> Like others in the referenced thread, I can reproduce this on Mac OS X
> 10.5.8 with R 2.14.1 using R.app but it works just fine from the
> Terminal CLI so it's likely something in the GUI rather than R itself:
> I'll forward this to R-SIG-Mac and see if Simon (Urbanek) picks it up.
> 

Interestingly, this is a bug in R: R_ReplDLLdo1() fails to invoke top-level handlers (txtStart uses top-level handler to collect values of expressions but the handler is never called). This may be a one-liner fix but I'll have to double-check tomorrow since changes in the REPL code tend to have bad consequences.

Thanks,
Simon


> 
> On Tue, Feb 14, 2012 at 3:50 PM, Simon Kiss <sjkiss at gmail.com> wrote:
>> Hello all:
>> I'm trying to use the following code to get commands, comments and results to a .txt file.  It only appears to capture comments. When I comment those out with #, it creates a NULL file.
>> Someone seemed to have a similar problem with a mac GUI (https://stat.ethz.ch/pipermail/r-help/2010-September/253177.html) but the result seemed to be ambiguous. Is there a work-around? Reproducible code and sessioninfo are below.   The OS is Mac OS 10.6.8.
>> 
>> Yours truly, Simon Kiss
>> 
>> install.packages("HSAUR")
>> library(HSAUR)
>> library(TeachingDemos)
>> data("Forbes2000", package="HSAUR")
>> #This is a test of R output for the blind
>> txtStart('test.txt', commands=TRUE, results=TRUE)
>> txtComment('This command provides the mean profit in the data set')
>> mean(Forbes2000$profits, na.rm=TRUE)
>> txtComment('This command provides the standard deviation of the profits data set')
>> sd(Forbes2000$profits, na.rm=TRUE)
>> txtComment('This command provides the average profit by country')
>> aggregate(Forbes2000$profits, by=list(Forbes2000$country), function(x) mean(x, na.rm=TRUE))
>> txtStop()
>> 
>> 
>> SessionInfo()
>> 
>> R version 2.13.2 (2011-09-30)
>> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>> 
>> locale:
>> [1] en_CA.UTF-8/en_CA.UTF-8/C/C/en_CA.UTF-8/en_CA.UTF-8
>> 
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>> 
>> other attached packages:
>> [1] TeachingDemos_2.7
>> 
>> loaded via a namespace (and not attached):
>> [1] tools_2.13.2
>> 
>> ______________________________________________
>> 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-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 
> 



More information about the R-help mailing list