简体   繁体   English

使用r-script与节点脚本进行R集成

[英]R integration with node script using r-script

I have two very simple files to test my integration setup. 我有两个非常简单的文件来测试集成设置。 First the r script inside test.R: 首先是test.R中的r脚本:

print('hello')

Then the index.js calling that file: 然后index.js调用该文件:

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. 当前,我正在运行Ubuntu 18.04,如果我仅运行Rscript test.R,则可以正常运行。 Any help? 有什么帮助吗?

I fix my similar issue with https://github.com/joshkatz/r-script/issues/19 我用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 如果您仍然懒于拉git,可以直接更新源代码./node_modules/r-script/index.js ,然后将函数init编辑为

function init(path) {
  var obj = new R(path);
  _.bindAll(obj, "data", "call", "callSync");
  return obj;
}

I hope you may find this helpful. 希望对您有所帮助。

 $ cd node_modules/r-script
 $ rm node_modules
 $ npm install underscore@1.8.3

in my case, downgrade underscore works 就我而言,降级强调

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM