inline::cxxfunction not displaying well in knitr

random_forest_fanatic

I'm having problems getting C++ code (written via the cxxfunction in the inline package) to display nicely when using knitr. Here's a MWE:

<html>
<body>

<!--begin.rcode
library(Rcpp)
library(inline)
test <- cxxfunction(signature(xR="numeric"), body="
  double x = as<double>(xR);
  return(wrap(x));
  ", plugin="RcppArmadillo")
end.rcode-->

</body>
</html>

When I knit this code, it reformats the body argument by replacing all new lines with "\n" and it makes it very hard to read. Are there any work-arounds to this?

Yihui Xie

There was a major change as listed in the release notes of knitr 1.6: the default chunk option tidy = TRUE was changed to FALSE. That is why your line breaks are no longer turned to literal \n's with knitr 1.6.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related