Matthieu Stigler
2009-Jan-20 11:53 UTC
[R] Sweave: conflict between setwd and \SweaveOpts{prefix.string=}
Hello I think there is a conflict between setwd() and \SweaveOpts{prefix.string=}. In the same document, those both command get Sweave confuse the files and directories. See: say my .Rnw document is in File1 If one inserts some setwd() for another file: -setwd(File2) then the command \SweaveOpts{prefix.string=graphics/Rplots} will search the "graphics" folder in File2 because of command setwd(File2) and not in File1 where the .Rnw file is and as is said in Sweave Manual A10. Hence Latex get really confused and does not work anymore: the command \includegraphics looks for folder "graphics" in the usual File1 but those can have been stored in File2. I tried to add some: \usepackage{graphicx} \graphicspath{{../File2/graphics/}} but resulot was not so convincing Is there anyway to avoid this? Thanks!
Duncan Murdoch
2009-Jan-20 12:04 UTC
[R] Sweave: conflict between setwd and \SweaveOpts{prefix.string=}
Matthieu Stigler wrote:> Hello > > I think there is a conflict between setwd() and > \SweaveOpts{prefix.string=}. In the same document, those both command > get Sweave confuse the files and directories. See: > > say my .Rnw document is in File1 > > If one inserts some setwd() for another file: > -setwd(File2) > > then the command \SweaveOpts{prefix.string=graphics/Rplots} will search > the "graphics" folder in File2 because of command setwd(File2) and not > in File1 where the .Rnw file is and as is said in Sweave Manual A10. > > Hence Latex get really confused and does not work anymore: the command > \includegraphics looks for folder "graphics" in the usual File1 but > those can have been stored in File2. > > I tried to add some: > \usepackage{graphicx} > \graphicspath{{../File2/graphics/}} > but resulot was not so convincing > > Is there anyway to avoid this? Thanks! >You could use a fully qualified prefix, so it doesn't matter what the current directory is when you save a plot. Or you could avoid setwd(). Or you could change back to the original directory before drawing a plot. It would probably make sense for Sweave to do the last of these internally: it is mixing up characteristics of the session it's running in with characteristics of the session it is running. However, this is a pretty strange case, and I'm not sure fixing it will be a high priority. Duncan Murdoch
ONKELINX, Thierry
2009-Jan-20 12:30 UTC
[R] Sweave: conflict between setwd and \SweaveOpts{prefix.string=}
Have you tried specifying an absolute path in prefix.string instead of a relative one? HTH, Thierry ------------------------------------------------------------------------ ---- ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 Thierry.Onkelinx at inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -----Oorspronkelijk bericht----- Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Namens Matthieu Stigler Verzonden: dinsdag 20 januari 2009 12:53 Aan: r-help at r-project.org Onderwerp: [R] Sweave: conflict between setwd and \SweaveOpts{prefix.string=} Hello I think there is a conflict between setwd() and \SweaveOpts{prefix.string=}. In the same document, those both command get Sweave confuse the files and directories. See: say my .Rnw document is in File1 If one inserts some setwd() for another file: -setwd(File2) then the command \SweaveOpts{prefix.string=graphics/Rplots} will search the "graphics" folder in File2 because of command setwd(File2) and not in File1 where the .Rnw file is and as is said in Sweave Manual A10. Hence Latex get really confused and does not work anymore: the command \includegraphics looks for folder "graphics" in the usual File1 but those can have been stored in File2. I tried to add some: \usepackage{graphicx} \graphicspath{{../File2/graphics/}} but resulot was not so convincing Is there anyway to avoid this? Thanks! ______________________________________________ R-help at 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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document.