Planeshifter / node-Rstats

[UNMAINTAINED] An interface for node.js to statistical programming language R based on the fabulous Rcpp package
GNU General Public License v2.0
59 stars 16 forks source link

R.get gives 'Error: could not find function "toJSON"' #6

Closed gunjankarun closed 10 years ago

gunjankarun commented 10 years ago

I am trying to execute the following nodejs code

var rstats  = require('rstats');
var util = require('util');
var R  = new rstats.session();
R.parseEvalQ("mat = matrix(1:4,ncol=2,nrow=2)");
var mat = R.get("mat");
console.log(util.inspect(mat))

I am getting Error: could not find function "toJSON" error on the line var mat = R.get("mat");

I have RJSONIO installed in R. I am running this on Ubuntu. Is there something that I should look out for?

Planeshifter commented 10 years ago

The error message indicates that the connection to R is running, but that R cannot find the toJSON function - implying that the RJSONIO package was not loaded. Your code works for me, but I might have had a bug in my code which prevented the RJSONIO library from loading. I have uploaded a new version of the package to npm, could you please install it and try to run your code again?
Best wishes, Philipp

gunjankarun commented 10 years ago

:+1: Yes, this fixed the problem. You are a rockstar :)