I am trying to use R's Brew package to write a report. I am starting by adopting some of the code from this webpage http://learnr.wordpress.com/2009/09/09/brew-creating-repetitive-reports/
I can use brew to make a PDF-able Tex file for something simple like this:
documentclass[11pt]{amsart}
\begin{document}
<% library(xtable); library(ggplot2) %>
<% for (i in 1:2) { %>
<%=print(i) %>
<% } -%>
\end{document}
but if i try to insert a simple cat command:
documentclass[11pt]{amsart}
\begin{document}
<% library(xtable); library(ggplot2) %>
<% for (i in 1:2) { %>
<%=cat("\section{", i, "}", sep="") %>
<% } -%>
\end{document}
i get the following error:
brew("Brew/test_brew3.brew", "Brew/test_brew2.tex")
Error: '\s' is an unrecognized escape in character string starting "\s"
Any thoughts about what might be going wrong? the \section command is called in the post above so I am wondering if it is something with my R environment?
Your problem has nothing to do with brew. You can replicate the error by calling:
cat("\section{", i, "}", sep="")
If you need a literal \
, you must escape it:
cat("\\section{", i, "}", sep="")
The lesson is, keep trying to replicate the error until you get to its minimally reproducible form. Or start with the most basic portion of the command and add components until the error occurs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With