I would like to know if it is possible to make a comment inside an Rnw file exercise so that something can be completely ignored by both R and LaTeX. This would be useful for me to have some flexibility building exercises.
In particular, I would like to make a multiple choice question with five options where two true statements and two wrong statements are given and another statement is chosen at random between a true statements and two wrong statements. Trying to acheive this as in http://www.r-exams.org/templates/boxplots/ turns out to be quite difficult for me because all these statements involve LaTeX coding so I have problems inserting it in a R chunck. So I have tried something different, but I get an error saying that the length of exsolution and questionlist does not match. Perhaps, there is some way to make the commenting works.
<<echo=FALSE, results=hide>>=
scelta=sample(c("%'","%'",""),size=3, replace=FALSE)
if (scelta[1]=="%'") soluz=c(1,1,rep(0,3)) else soluz=c(1,1,1,0,0)
@
\begin{question}
Say which statements are true.
\begin{answerlist}
\item first true statement
\item second true statement
\Sexpr{scelta[1]} \item third true statement
\item first wrong statment
\item second wrong statment
\Sexpr{scelta[2]} \item statment
\Sexpr{scelta[3]} \item statement
\end{answerlist}
\end{question}
\begin{solution}
<<echo=FALSE, results=tex>>=
answerlist(ifelse(soluz, "Vero", "Falso"))
@
\end{solution}
\exname{name_exercise}
\extype{mchoice}
\exsolution{\Sexpr{mchoice2string(soluz)}}
\exshuffle{5}
So, probably I have difficulties because I am not enough familiar with Sweave, but my problem perhaps can be addressed in multiple ways through R/exams. Any help would appreciated.