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

knitrrsweave

I'm trying to insert a figure using Sweave which is located in the path C:\Users\eccehomo\Documents\mi\fig1.png. I'm using the package knitrwhich has a function called fig.pathbut I'm getting many errors for such a simple thing! Here's one of the things I have tried:

<<fig1,fig=TRUE>>=
library(knitr)
f='C:/Users/eccehomo/Documents/mi/fig1.png'
@

\includegraphics{f}

Best Answer

Use \includegraphics{\Sexpr{f}}. LaTeX does not know the variables in R.