Let me clarify a little bit about me comments on SO: setwd() should be called in the first place before you work on anything, and it should never be used in the middle of a project (if you do, you need to restore it later). Presumably Sweave writes the output file using something like cat(output, file = 'yourfile.tex'); if you changed your working directory before that, the tex file will be written to an unexpected place.
Regards, Yihui -- Yihui Xie <xieyi...@gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Mon, Nov 5, 2012 at 10:58 AM, Jessica Streicher <j.streic...@micromata.de> wrote: > I'll second the full path option. > > Just create a variable path_to_data and concatenate it with the names of any > files you need in that directory. > You could also try to use relative paths if the data is "nearby" and is > likely to not change that position. > > e.g. if the data was in '/home/r/Documents/mydata/whatever.txt', while you > are working in '/home/r/Documents/myproj/', you can reach that directory via > '../mydata/whatever.txt'. > > > On 05.11.2012, at 16:23, Riccardo Romoli 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 ______________________________________________ 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.