On Nov 5, 2012, at 9:23 AM, Riccardo Romoli <ric.rom...@gmail.com> wrote:
> Dear R list, > I'm using R 2.15.2 with TeX Live 2009 and ESS 12.09 . I have a R > project in the '/home/r/Documents/myproj/', which is my working > directory (where I have the .Rnw file). Inside the document I have > several "setwd()" to collect the datasets I use. > > After I compile from the terminal using "R CMD Sweave myproj.Rnw", I > receive the error: > > Error in driver$finish(drobj) : > the output file 'myproj.tex' has disappeared > Calls: <Anonymous> -> do.call -> <Anonymous> -> <Anonymous> > Execution halted > > but the file "myproj.tex" is produced and if I compile it using > "pdflatex myproj.tex" all works fine. > > Googling I found a similar problem but that guy have problem also > compiling the tex file. I found enteresting a comment: "Thou shall > never setwd() inside a report! setwd() should always be kept out of a > report [...]". This is what I found: > http://stackoverflow.com/questions/12162092/r-sweave-output-error > > Anyone knows why that happens?? Have you any idea about this kind of > error?? How can I solve this problem without moving the files and the > folders where I have the data sets?? > > Best > Riccardo You would need to dig into the Sweave code, but presumably, once you change the current working directory, certain aspects of the environment in which Sweave is operating are changed. Perhaps not all, since some things still seem to work. I have never used setwd() within a .Rnw file, not because of prior experience, but because I have never needed to. Just use the full path to whatever external files you need, rather than changing the working directory in order to avoid using the full path. That has worked for me over hundreds of Sweave reports over the course of many years. Regards, Marc Schwartz ______________________________________________ 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.