gpt4 book ai didi

R 使用 r-script 与 Node 脚本集成

转载 作者:太空宇宙 更新时间:2023-11-03 17:07:06 25 4
gpt4 key购买 nike

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

print('hello')

然后 index.js 调用该文件:

var R = require("r-script");
var out = R("./test.R")
.data()
.callSync();

这就是我的控制台告诉我的:

$ node index.js
/home/user/index.js:3
.data()
^

TypeError: Cannot read property 'data' of undefined

目前,我正在运行 Ubuntu 18.04,如果我只运行 Rscript test.R,它可以正常工作。有帮助吗?

最佳答案

我用 https://github.com/joshkatz/r-script/issues/19 解决了我的类似问题

如果你还是懒得拉git,可以直接更新源码./node_modules/r-script/index.js,然后编辑函数init 作为

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

希望对您有所帮助。

关于R 使用 r-script 与 Node 脚本集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50093298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com