使用r-script与节点脚本进行R集成 [英] R integration with node script using r-script

查看:63
本文介绍了使用r-script与节点脚本进行R集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个非常简单的文件来测试集成设置.首先是test.R中的r脚本:

I have two very simple files to test my integration setup. First the r script inside test.R:

print('hello')

然后index.js调用该文件:

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

当前,我正在运行Ubuntu 18.04,如果仅运行Rscript test.R,则可以正常运行.有帮助吗?

Currently, I am running Ubuntu 18.04 and if I run only Rscript test.R it works with no problem. Any help?

推荐答案

我用如果您仍然不愿意拉git,可以直接更新源代码 ./node_modules/r-script/index.js ,然后编辑功能 init

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.

这篇关于使用r-script与节点脚本进行R集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆