[Tex/LaTex] insert figure in sweave using knitr fig.path Version 2

knitrrsweave

I have a question similar to this post.

I am trying to add a .jpg to a .Rnw file (compiling LaTex with RSweave and knitr). I've tried the following without success:

<<IMAG0387.jpg,fig=TRUE>>=
library(knitr)
f <- 'M:/QW Monitoring Team/GLRI toxics/Phase II/Wastewater Intensive/Sniffer/Leaf_Experiments/photos/IMAG0387.jpg'
@
\includegraphics{f}

I'm getting an error:

You can now run (pdf)latex on 'Sam_Report_Actual.tex'
Warning message:
file stem 'Sam_Report_Actual-IMAG0387.jpg' is not portable 
Running pdflatex.exe on Sam_Report_Actual.tex...failed

Note that Sam_Report_Actual is the name of the .Rnw file. I've checked C:\Program Files (x86)\MiKTeX 2.9\miktex\bin on my coputer and I have pdflatex.exe so I'm not sure what's going on. Suggestions?

Best Answer

Sigh, since you have read the post that you linked to, why did you still write \includegraphics{f} (which is apparently wrong according to the answer to that post)?

Please post the full error message (presumably in Sam_Report_Actual.log), and avoid using absolute paths (always use relative paths if possible) and spaces in file paths (use _ or - instead).