Unable to integrate Rcpp package of renjin

64 views Asked by At

I am trying to integrate r code in java and want to use c++ code in r code, but i am getting the following error.

"org.renjin.eval.EvalException: Could not resolve native method 'sourceCppContext' in package 'Rcpp'"

while running my java code.

My Java Code piece:

r.eval(String.format("source(\"" + appdir +  "/config/MyRscript.R\")"));
String rS = ((SEXP)r.eval("test("+i+")")).toString();

R code :

library(Rcpp)
sourceCpp("Rfunction.cpp")

test <- function(a) {
   x <<- timesTwo(a)
   print(x)
}

C++ code :

#include <Rcpp.h>
using namespace Rcpp;

int timesTwo(int x) {
    return x * 2;
}
1

There are 1 answers

0
akbertram On

Renjin doesn't, and probably can't reasonably support sourceCpp(). You need to either move your C++ code to package where it can be compiled to JVM bytecode at build time, or rewrite in R or Java.