问题
I have two very simple files to test my integration setup. First the r script inside test.R:
print('hello')
Then the index.js calling that file:
var R = require("r-script");
var out = R("./test.R")
.data()
.callSync();
And this is what my console is telling me:
$ node index.js
/home/user/index.js:3
.data()
^
TypeError: Cannot read property 'data' of undefined
Currently, I am running Ubuntu 18.04 and if I run only Rscript test.R it works with no problem. Any help?
回答1:
I fix my similar issue with https://github.com/joshkatz/r-script/issues/19
If you still feeling lazy to pull the git, you can directly update the source code ./node_modules/r-script/index.js , then edit the function init as
function init(path) {
var obj = new R(path);
_.bindAll(obj, "data", "call", "callSync");
return obj;
}
I hope you may find this helpful.
回答2:
$ cd node_modules/r-script
$ rm node_modules
$ npm install underscore@1.8.3
in my case, downgrade underscore works
来源:https://stackoverflow.com/questions/50093298/r-integration-with-node-script-using-r-script