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?
Error installing and running rcpp
In the end it was something a bit left-field. Inspired by the following post, I had a look at the ComSpec
environment variable. Not quite sure how, but I had it set to "cmd.exe"
.
Removing the double quotes, so it said cmd.exe
, and then rebooting fixed everything.
Thanks to all who've tried to help.
Related Topics
Why Are Xs Added to Data Frame Variable Names When Using Read.Csv
Finding Elements That Do Not Overlap Between Two Vectors
How to Screenshot a Website Using R
Adding Total/Subtotal to the Bottom of a Datatable in Shiny
Connecting Points with Lines in Ggplot2 in R
How to Draw Two Half Circles in Ggplot in R
Extracting Noun+Noun or (Adj|Noun)+Noun from Text
Counting Unique Items in Data Frame
How to Use a MACro Variable in R? (Similar to %Let in Sas)
How to Correctly Interpret Ggplot's Stat_Density2D
How to Create Datatable with Complex Header in R Shiny
Visualise Distances Between Texts
How to Manually Create a Dendrogram (Or "Hclust") Object? (In R)
R How to Read a File from Google Drive Using R
How to Order a Data Frame by One Descending and One Ascending Column
Passing String Variable Facet_Wrap() in Ggplot Using R
Conditional Rolling Mean (Moving Average) on Irregular Time Series