简体   繁体   English

Nodejs r-script 只返回 NULL

[英]Nodejs r-script only returns NULL

So I'm trying to run an R-script from a nodejs express REST API.所以我试图从 nodejs express REST API 运行 R 脚本。 I've done everything exactly as described on their Github page https://github.com/joshkatz/r-script .我已经按照他们的 Github 页面https://github.com/joshkatz/r-script中的描述完成了所有工作。

The only output I get is null .我得到的唯一 output 是null Even if the R script only prints something there is no output.即使 R 脚本只打印一些东西,也没有 output。

.node_modules/
.routes/
...rscript.js
.index.js
.ex-sync.R

nodejs:节点:

    const out = R("../ex-sync.R")
        .data("hello world", 20)
        .callSync();

    console.error(out);
    // null

R: R:

needs(magrittr)
set.seed(512)
do.call(rep, input) %>% 
  strsplit(NULL) %>% 
  sapply(sample) %>% 
  apply(2, paste, collapse = "")

You entered the ex-sync.R file address incorrectly, chenged to您输入的ex-sync.R文件地址错误,改为

const out = R("ex-sync.R")

You need to manually add R-Script folder(C:\Program Files\R\R-4.1.2\bin) to the Windows Path on This PC>Advance Settings>Environment Variables>System Variables您需要手动将 R-Script 文件夹(C:\Program Files\R\R-4.1.2\bin)添加到此 PC 上的 Windows 路径>高级设置>环境变量>系统变量

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

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