Re: [R] Rgui maintains open file handles after Sweave error

2012-04-05 Thread Alexander Shenkin
Here is Dr. Leisch's advice for dealing with open handles (and it works): On 4/5/2012 4:22 AM, Friedrich Leisch wrote: ... You need to close the pdf device, not an open connection: R Sweave(test.Rnw) Writing to file test.tex Processing code chunks with options ... 1 : keep.source term

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-05 Thread Duncan Murdoch
On 04/04/2012 3:25 PM, Alexander Shenkin wrote: Hello Folks, When I run the document below through sweave, rgui.exe/rsession.exe leaves a file handle open to the sweave-001.pdf graphic (as verified by process explorer). Pdflatex.exe then crashes (with a Permission Denied error) because the

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-05 Thread Alexander Shenkin
Thanks for the nice ideas, Duncan. I think that would work nicely in most cases. The major issue with that workflow in my case is that the scripts to set up my workspace take around a half-hour to run (I really wish CUDA was working with my setup!), so running R each time in that case is

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-05 Thread Yihui Xie
In terms of editors, I think RStudio is pretty good (http://www.rstudio.org/download/preview). Or LyX (http://yihui.name/knitr/demo/lyx/), or TeXmaker, WinEdit (http://yihui.name/knitr/demo/editors/)... All of them start a new R session when weaving the document, and all support one-click

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-05 Thread Alexander Shenkin
Yep, I'm using RStudio, and have used Tinn-R in the past. RStudio does start a new R session when processing a sweave document via the RStudio GUI. In my case, this presented a problem for the reasons I stated before (i.e. that I need to run sweave in the main environment, not a new one).

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-05 Thread Yihui Xie
Well, I do not think it is a good practice (in terms of reproducible research) to keep on running Sweave in the same R session, because your previous run and your current workspace could pollute your next run. To make sure a document compiles on its own, it is better always to start a new clean R

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-05 Thread Alexander Shenkin
Reproducibility is important, and as I mentioned in a previous email, there are probably ways I could avoid running the entire script over and over again with each sweave compilation. Still, relying on saved workspaces, temporary files or caches still has some of the issues that working in the

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-05 Thread Yihui Xie
Things are not that gory with knitr. You only need to use the option cache=TRUE and it will take care of most of the things you mentioned. For example, objects in a chunk are automatically saved and lazy loaded; when code is modified, old cache will be automatically removed and new cache will be

[R] Rgui maintains open file handles after Sweave error

2012-04-04 Thread Alexander Shenkin
Hello Folks, When I run the document below through sweave, rgui.exe/rsession.exe leaves a file handle open to the sweave-001.pdf graphic (as verified by process explorer). Pdflatex.exe then crashes (with a Permission Denied error) because the graphic file is locked. This only seems to happen

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-04 Thread Henrik Bengtsson
See ?closeAllConnections Suggestion to the maintainer of Sweave: atomify the figure generation, e.g. use { pdf(); on.exit(dev.off()); {...}; } or similar, instead of { pdf(); {...}; dev.off(); } possibly by leaving a copy of the fault figure file for troubleshooting. /Henrik On Wed, Apr 4, 2012

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-04 Thread Alexander Shenkin
Thanks for the reply, Henrik. Process Explorer still shows the file handle as being open, but R only shows the following: showConnections(all=TRUE) description class mode text isopen can read can write 0 stdin terminal r text opened yesno 1 stdoutterminal w text opened

Re: [R] Rgui maintains open file handles after Sweave error

2012-04-04 Thread Yihui Xie
Herik's suggestion is an absolutely good practice which guarantees the device is always closed. That is what I did in the knitr package, so you can probably take a look at http://yihui.name/knitr/ Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department