Reputation: 306
So I'm trying to run an R-script from a nodejs express REST API. I've done everything exactly as described on their Github page https://github.com/joshkatz/r-script.
The only output I get is null
. Even if the R script only prints something there is no 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:
needs(magrittr)
set.seed(512)
do.call(rep, input) %>%
strsplit(NULL) %>%
sapply(sample) %>%
apply(2, paste, collapse = "")
Upvotes: 0
Views: 186
Reputation: 1
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
Upvotes: 0
Reputation: 5051
You entered the ex-sync.R
file address incorrectly, chenged to
const out = R("ex-sync.R")
Upvotes: 1