I am trying to call R program from Node which will call hist function. I am using npm package r-script - https://www.npmjs.com/package/r-script
below is my R code
x <- c(1,2,3,4,5,6,6)
hist(x, col="lightblue")
and here is index.js
var express = require('express');
var R = require("r-script");
var app = express(); app.get('/', function (req, res)
{
var out = R("example/sample.R")
.data("hello world", 20)
.callSync();
console.log(out);
})
var server = app.listen(8081, function () { var port = server.address().port
console.log(`Example app listening at http://localhost:${port}`)})
But when I execute this code, I am getting error as below
Error: No method asJSON S3 class: histogram
Execution halted
Am I missing anything?