Rcpp issue

Mar 15, 2014 at 11:29 AM
Firstly, This project and the work you're doing is fantastic. So thanks!

Secondly, I'm having a little bit of trouble loading RCPP files via R.NET, the following works fine in the R console but refuses to load via R.NET. The commands passed into R.NET are:

rm(list=ls())
library(Rcpp)
require("Rcpp")
setwd("C:/RCODEHERE")
sourceCpp("layers.cpp")

I've taken the latest from the 'jperraud' branch which throws the following in my application:

"Error in system(cmd, ignore.stderr = TRUE, intern = TRUE) : \n 'C:/Program' not found\n

Im not sure what that path refers to (maybe the rcpp installation?) and it looks like its having a little trouble with the whitespace in "Program Files"

Any help is much appreciated,

J
Developer
Mar 16, 2014 at 1:36 AM
I think I've fixed it. Code is committed on that same 'jperraud' branch.
Thanks for reporting this; it led to fixing something rather important. Basically the root cause was that R_HOME ends up set with long directory paths with dreaded blanks instead of short old style DOS 8.3 paths. Not sure whether this is an R bug and/or R.NET; anyway now R.NET makes sure short path names for R_HOME are used in all cases.
More detailed information for the record at issue 97

I can now run to completion:
         REngine.SetEnvironmentVariables();
         using (REngine e = REngine.GetInstance())
         e.Evaluate("library(Rcpp)");
         e.Evaluate("setwd('c:/tmp')");
         e.Evaluate("sourceCpp('fibonacci.cpp')");
         var x = e.Evaluate("fibonacci(7)").AsNumeric();
using the example for the manual page of Rcpp::sourceCpp
#include <Rcpp.h>

// [[Rcpp::export]]
int fibonacci(const int x) {
if (x == 0) return(0);
if (x == 1) return(1);
return (fibonacci(x - 1)) + fibonacci(x - 2);
}
sessionInfo:
R version 3.0.3 (2014-03-06)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] Rcpp_0.10.6

loaded via a namespace (and not attached):
[1] tools_3.0.3
Mar 16, 2014 at 9:53 AM
Absolutely spot on! Thanks.

I came across a couple of issues when the registry values are searched for but I think this may be because Im running R 2.15.3 and the registry structure might be slightly different, R-core/R/2.15.3 has the "InstallPath" key and I cant find any "CurrentVersion" key but once I overcame that the latest commit solved the Rcpp issue.

Thanks again for all your hard work, its much appreciated.