R integration with node script using r-script

半腔热情 提交于 2019-12-24 07:28:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!