Hi,
My appologies—I had looked at Stack Overflow about 4 hours ago and for some reason did not see your reply.
I tried removing “cache = TRUE” with no results.
I then followed your suggestion and updated to R2.15.2 and updated all my installed packages.
Then I just wiped out anything that appeared connected to the .Rnw or .tex files and created a bare-bones example that works and then does not.
It appear that my problem is coming from what directory I output to.
knit("~/Latex/aknit1.Rnw") ===>> output file: /home/john/aknit1.tex
works just fine.
knit("~/Latex/aknit1.Rnw", output = "~/Latex/aknit1.tex") ===>>
output file: /home/john/Latex/aknit1.tex
does not work on a second compile.
So presumably I am deleting something ? I have no idea how I am doing it.
=============bare bones example==============
\documentclass[12pt,letterpaper]{apa6} \usepackage[utf8]{inputenc} \usepackage[english]{babel} \author{John Kane} \begin{document} <<one.plot>>= mydata <- data.frame(aa = 1:10, bb <- 10:1) plot(mydata$aa, mydata$bb) @ \end{document}
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: i686-pc-linux-gnu (32-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_0.8
loaded via a namespace (and not attached):
[1] digest_0.5.2 evaluate_0.4.2 formatR_0.6 plyr_1.7.1 stringr_0.6.1
[6] tools_2.15.2
This is a hard decision for me -- I offend some users if I do not
write output relative to the current working directory, and offend
other users if I do. I have been thinking about what to do in the case
where the tex output is under a different directory. I can come up
with an automatic solution, but then I may have to come up with yet
another solution to cancel this solution if the user does not like it.
For Emacs/ESS, see these lines where they setwd():
https://github.com/emacs-ess/ESS-mirror/blob/trunk/lisp/ess-swv.el#L122-L126
You are right that this problem is not clearly documented, partly
because most users rarely use knitr that way (the output argument does
not need to be specified). You are the first one I see who was bitten
by this problem.
The unclear documentation is at http://yihui.name/knitr/options;
search for base.dir and that can solve your problem, e.g.
opts_knit$set(base.dir = '~/Latex/')
But as I said, it is better to set a working directory for your
project before you work on anything else. It is not only about knitr,
but also about reading data files and writing output, etc. Normally I
just
cd ~/Latex
R
Then you do not need to worry if you are under ~/Latex or ~/What/ever,
and you are free to copy and distribute the project to anywhere else
since relative paths are portable.
Regards,
Yihui