Can't use Rcpp engine in R Markdown

With the requested information of the Sys.getenv['PATH'] not containing a path with Rtools in it and the knowledge that the knitr error is being triggered by an invalid engine path, I think you are falling victim to devtools::find_rtools() throwing a false positive on setup.

This is typically the case since if it is unable to find Rtools on the system path, it scans for Rtools within the registry and then sets an environment flag. The environment flag does not typically persist while running rmarkdown or during the package build stage. Also see: Why do I need to run find_rtools() before has_devel() = TRUE?

E.g. If you close all open session R sessions, then open a new R session and only type Rcpp::evalCpp("2 + 2") you will likely trigger a compile error.

The fix for this is simple: Add the Rtools install location to the PATH system variable. I maintain an installation guide that literally takes you step-by-step through this process here: http://thecoatlessprofessor.com/programming/rcpp/install-rtools-for-rcpp/

As of Rtools 3.4, the two locations that must be added to the PATH are:

c:\Rtools\bin;
c:\Rtools\mingw_32\bin;

To modify your PATH variable on windows see either:

  • How do I set system environment variables in Windows 10?
  • What are PATH and other environment variables, and how can I set or use them?