-
-
Notifications
You must be signed in to change notification settings - Fork 218
Closed
Description
When there is some space in R path, sourceCpp failed to compile:
library(Rcpp)
code2 = "#include <Rcpp.h>\n\nusing namespace Rcpp;\n\n// [[Rcpp::export]]\nint fibonacci(const int x) {\n if (x == 0) return(0);\n if (x == 1) return(1);\n return (fibonacci(x - 1)) + fibonacci(x - 2);\n }"
sourceCpp(code = code2)
It showed the error:
Error in system(cmd, intern = !showOutput) : 'd:/Program' not found
> sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Rcpp_1.0.9
loaded via a namespace (and not attached):
[1] compiler_4.2.1 tools_4.2.1
A possible solution is to add the command r <- paste0('"', r, '"')
after the command r <- paste(R.home("bin"), "R", sep = .Platform$file.sep)
.
After done that, it compiles normally.
> fibonacci(10)
[1] 55
Metadata
Metadata
Assignees
Labels
No labels