Insert multiple images in for

I have five images stored as follows (where "currentDirectory" is the result I get from the command getwd()):

currentDirectory/results/thePlot_1.jpg
currentDirectory/results/thePlot_2.jpg
currentDirectory/results/thePlot_3.jpg
currentDirectory/results/thePlot_4.jpg
currentDirectory/results/thePlot_5.jpg

I am trying to write a .Rnw script in Rstudio that will create the .tex file that I can then run pdflatex on to have a .pdf file containing these five images. Below is what I currently have tried:

documentclass{article}
usepackage{float, hyperref}
usepackage[margin=1in]{geometry}
usepackage{graphicx}
usepackage{hyperref}
usepackage{caption}
usepackage{algorithm}
usepackage{algorithmic}

begin{document}
SweaveOpts{concordance=TRUE}

<<include=FALSE>>=
library(knitr)
opts_chunk$set(
concordance=TRUE
)
@

author{myName}
title{myTitle}

maketitle

<<echo=FALSE>>==
library(ggplot2)
library(GGally)
library(stringr)
library(dplyr)
library(matrixStats)
library(gridExtra)
library(reshape2)
@

.

section*{mySection}

FOR{i in 1:5}
Sexpr{nPlots=i}
Sexpr{plotName = "thePlot"}
Sexpr{outDir = "results"}
includegraphics{Sexpr{paste(getwd(), "/", outDir , "/", plotName, "_", i, sep="")}}
ENDFOR

end{document}

I get an error:

"Object 'i' not found"

for the the line Sexpr{nPlots=i}.

I had posted a similar question at (Insert multiple images in for-loop into Sweave Document), and was suggested to open it here after incorporating a few suggestions.

链接地址: http://www.djcxy.com/p/26920.html

上一篇: 如何在Android上显示警告对话框?

下一篇: 在for中插入多个图像