I can't get the following to work:
\begin{minipage}
<<percentile, echo=FALSE>>=
your_rank <- percentile ## calculated earlier
rank_message <- ifelse(is.na(score), ' ', paste0("You are in the top ", your_rank, "% of participants."))
@
\begin{center}
\fbox{
\parbox{15cm}{\centering
\textbf{\Sexpr{rank_message}} \\
} % End parbox
} % End fbox
\end{center}
\end{minipage}
I get the error:
File ended when scanning use of \fbox
Then, if I put \ before the % ie
paste0("You are in the top ", your_rank, "\% of participants.")
then the R part gives me an error:
Error in eval(parse_only(code), envir = envir) :
How can I get around this?
Update - putting the R chunk in a group doesn't work. Here is a working example - with the percentage symbol removed:
\documentclass[a4paper]{article}
\usepackage{fullpage}
\usepackage{pdflscape} % landscape format
\begin{document}
\begin{landscape}
\begin{minipage}[t][5cm]{0.6\linewidth}
\begingroup\catcode`\%=12
<<percentile, echo=FALSE>>=
score <- 10
your_rank <- 30
rank_message <- ifelse(is.na(score), ' ', paste0("You are in the top ", your_rank, " of participants"))
@
\endgroup
\begin{center}
\fbox{
\parbox{15cm}{\centering
\textbf{\Sexpr{rank_message}} \\
} % End parbox
} % End fbox
\end{center}
\end{minipage}
\end{landscape}
\end{document}
Update: Ross's comment did the trick. Thanks Ross.

\begingroup\catcode%=12 <