Search code examples
rcaller

Can't get RCaller to work, get error on line caller.runAndReturnResult


I am trying to use Rcaller with simple example code as follows

 public class rcaller {

    public static void main(String[] args) {

        RCaller caller = RCaller.create();
        RCode code = RCode.create();

        double[] arr = new double[] { 1.0, 2.0, 3.0 };
        code.addDoubleArray("myarr", arr);
        code.addRCode("avg <- mean(myarr)");
        
        caller.setRCode(code);
        caller.runAndReturnResult("avg");
        double[] result = caller.getParser().getAsDoubleArray("avg");
        System.out.println(result[0]);
    }

}

I am getting the following error on the line runAndReturnResult:

Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in opaque part at index 2: C:\Users\uceesro\AppData\Local\Temp\ROutput11009463111314803062
    at java.base/java.net.URI.create(URI.java:906)
    at com.github.rcaller.rstuff.RCode.appendStandardCodeToAppend(RCode.java:109)
    at com.github.rcaller.rstuff.RCaller.runAndReturnResult(RCaller.java:576)
    at rcaller.rcaller.main(rcaller.java:21)
Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\Users\uceesro\AppData\Local\Temp\ROutput11009463111314803062
    at java.base/java.net.URI$Parser.fail(URI.java:2938)
    at java.base/java.net.URI$Parser.checkChars(URI.java:3109)
    at java.base/java.net.URI$Parser.parse(URI.java:3145)
    at java.base/java.net.URI.<init>(URI.java:623)

I have tried using different versions of R but get the same issue. Any help would be appreciated.


Solution

  • "Found issue seems to be a problem with rcaller 4.0.0" — yes, this problem really exists on Windows (and had not been found during the development and CI tests). Please try 4.0.1