Closed MartinInFrankfurtAM closed 13 years ago
This is quite likely to be my fault...
Cameron, I will look into this issue first.
Confirmed. It is completely my fault in LyX configuration. I was not aware that users might use setwd()
to change the working directory -- I never do that in my R code because this is not reproducible.
@MartinInFrankfurtaM: I have updated my R code for LyX to run Sweave: http://gitorious.org/yihui/lyx-sweave/blobs/raw/master/lyx-sweave-exec.R
You can either download that script and put it under ~/.lyx/scripts/
, or simply run my auto-configuration script again (source("http://gitorious.org/yihui/lyx-sweave/blobs/raw/master/lyx-sweave-config.R")
).
Maybe I need to clarify that the working directory for R in LyX is the just the directory where you LyX document comes from. Usually I put all the files needed in the same directory as my LyX documents, so I can use relative directories to read/write files. This is better for reproducibility (when you work with others, or on two computers)
Ahh... I just realized I committed another crime in my LyX demo: externalize=TRUE
is a typo -- should be external=TRUE
. This is terrible. I don't know how many users were mislead by this typo. Externalizing is so important to pgfSweave
...
Thanks for clearing this up, I had no idea how to go about it....
Not quite worst-case proof yet. The tikz-files are still stored in what I set in setwd() - and not found by latex in the next step. Forewarned is forearmed, however. You may still argue that a man who cannot dance should not get a sword to begin with.
Haha, thanks for teaching me proverbs. I did not know the last one.
This time, however, I think the problem is really out of my control. I've corrected my fault.
This is not pgfSweave's problem either -- I think it comes from the fact that Sweave uses relative paths to write the plots instead of using absolute paths, so the the plots will not be in the same directory with the .tex
file if you have changed the working directory in your R code.
I agree such a problem should be fixed, but I have no idea about how the R core (or the authors of Sweave) would think.
Again, I really do not recommend you to use setwd()
anywhere in Sweave. Anyway, you might want to wrestle with R core :)
Thank you, Yihui. I had better learn to dance with R first, however.
Example Lyx-code chunks: Not sure the following setup chunk is essential (just FYI)
It might prevent some hairs turning grey if this were documented somewhat prominently or -better - if the change in wd would be intercepted and reversed outside the user code.