Here's what I'd like to do, in my Rhtml document:
<!--begin.rcode
if (errors==1) {
end.rcode-->
<p>You have an error!</p>
<!--begin.rcode
end.rcode-->
Basically, I'm trying to use knitr like PHP. The above doesn't work, but is there a right way to do it?
This question is different from Conditional `echo` (or eval or include) in rmarkdown chunks. That is about how to conditionally evaluate a knitr "chunk". This is about how to conditionally evaluate the "normal" HTML (or TeX, or Markdown) in between two knitr chunks.
knitr
, then you might give a try topander
with<% ... %>
tags for conditionals and<%= ... %>
for printing markdown: rapporter.github.io/pander/#brew-to-pandoc, otherwise you might want tobrew::brew
your document before passing toknitr
. Or maybe there's an internalknitr
support for this, I'm not sure :) – daroczigcat
statement in a conditionally evaluated chunk. – Thomasbrew
is one way to go. But I would like to know if there is aknitr
solution. – user3603486