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 verbatim pdf > > Error: chunk 1 > Error in plot.xy(xy, type, ...) : object 'foo' not found > R> ls() > [1] "col.yellowbg" "df" > R> dev.list() > pdf > 2 > R> dev.off() > null device > 1 > Best, > Fritz
On 4/4/2012 2:52 PM, Alexander Shenkin wrote: > 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" "yes" "no" > 1 "stdout" "terminal" "w" "text" "opened" "no" "yes" > 2 "stderr" "terminal" "w" "text" "opened" "no" "yes" >> > > On 4/4/2012 2:45 PM, Henrik Bengtsson wrote: >> 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 at 12:25 PM, Alexander Shenkin <ashen...@ufl.edu> 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 graphic file is locked. >>> >>> This only seems to happen when there is an error in the sweave document. >>> When there are no errors, no file handles are left open. However, once >>> a file handle is stuck open, I can find no other way of closing it save >>> for quitting out of R. >>> >>> Any help would be greatly appreciated! It would be nice to be able to >>> write flawless sweave every time, but flawed as I am, I am having to >>> restart R continuously. >>> >>> Thanks, >>> Allie >>> >>> >>> OS: Windows 7 Pro x64 SP1 >>> >>> >>>> sessionInfo() >>> R version 2.14.2 (2012-02-29) >>> Platform: i386-pc-mingw32/i386 (32-bit) >>> >>> >>> test.Rnw: >>> >>> \documentclass{article} >>> \title {file handle test} >>> \author{test author} >>> \usepackage{Sweave} >>> \begin {document} >>> \maketitle >>> >>> \SweaveOpts{prefix.string=sweave} >>> >>> \begin{figure} >>> \begin{center} >>> >>> <<fig=TRUE, echo=FALSE>>= >>> df = data.frame(a=rnorm(100), b=rnorm(100), group = c("g1", >>> "g2", "g3", "g4")) >>> plot(df$a, df$y, foo) >>> @ >>> >>> \caption{test figure one} >>> \label{fig:one} >>> \end{center} >>> \end{figure} >>> \end{document} >>> >>> >>> >>> Sweave command run: >>> >>> Sweave("test.Rnw", syntax="SweaveSyntaxNoweb") >>> >>> >>> >>> Sweave.sty: >>> >>> \NeedsTeXFormat{LaTeX2e} >>> \ProvidesPackage{Sweave}{} >>> >>> \RequirePackage{ifthen} >>> \newboolean{Sweave@gin} >>> \setboolean{Sweave@gin}{true} >>> \newboolean{Sweave@ae} >>> \setboolean{Sweave@ae}{true} >>> >>> \DeclareOption{nogin}{\setboolean{Sweave@gin}{false}} >>> \DeclareOption{noae}{\setboolean{Sweave@ae}{false}} >>> \ProcessOptions >>> >>> \RequirePackage{graphicx,fancyvrb} >>> \IfFileExists{upquote.sty}{\RequirePackage{upquote}}{} >>> >>> \ifthenelse{\boolean{Sweave@gin}}{\setkeys{Gin}{width=0.8\textwidth}}{}% >>> \ifthenelse{\boolean{Sweave@ae}}{% >>> \RequirePackage[T1]{fontenc} >>> \RequirePackage{ae} >>> }{}% >>> >>> \DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl} >>> \DefineVerbatimEnvironment{Soutput}{Verbatim}{} >>> \DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl} >>> >>> \newenvironment{Schunk}{}{} >>> >>> \newcommand{\Sconcordance}[1]{% >>> \ifx\pdfoutput\undefined% >>> \csname newcount\endcsname\pdfoutput\fi% >>> \ifcase\pdfoutput\special{#1}% >>> \else\immediate\pdfobj{#1}\fi} >>> >>> ______________________________________________ >>> R-help@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-help@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-help@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.