[R] Rgui maintains open file handles after Sweave error

Alexander Shenkin ashenkin at ufl.edu
Thu Apr 5 19:47:57 CEST 2012


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 main environment does.  Specifically, you're not working
with the base data all the way through the final analyses each time you
run the sweave doc.  To produce those workspace, files or caches
requires a run of scripts.  If those scripts have changed, or if your
data have changed, then your workspace, files and/or cache is then just
as out of date as your workspace.  Saving workspaces, files and/or
caches still requires care that they're not saved after having been
modified by the command line, etc.  I think that working with saved
workspaces, files and/or caches is probably less prone to "pollution"
than working in the main environment, but it's far from failsafe.

As long as the final sweave doc is run with scripts from beginning to
end, getting the sweave doc up to snuff by working more quickly in the
main environment is acceptable IMHO.  So is working with the other
methods above.

Best,
Allie

On 4/5/2012 12:34 PM, Yihui Xie wrote:
> 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 session. If you run into speed issues (e.g. you
> have chunks which require intensive computing), you can consider using
> cache, which the knitr package has reasonably good support.
>
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui at gmail.com>
> Phone: 515-294-2465 Web: http://yihui.name
> Department of Statistics, Iowa State University
> 2215 Snedecor Hall, Ames, IA
>
>
>
> On Thu, Apr 5, 2012 at 12:26 PM, Alexander Shenkin <ashenkin at ufl.edu> wrote:
>> 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).  Hence, I'm running Sweave from the command line, and
>> processing the tex doc via TeXworks (from MiKTeX).  I sent the RStudio
>> team a feature request to add an option to be able to run Sweave in the
>> main environment (perhaps while maintaining the default of running it in
>> a separate environment).
>>
>> Allie
>>



More information about the R-help mailing list