joshkatz / r-script

A simple little module for passing data from NodeJS to R (and back again).
MIT License
161 stars 67 forks source link

Error - subscript out of bounds #35

Closed deshanm closed 5 years ago

deshanm commented 5 years ago

How to fix this issue..

{"output":[null,"","\nAttaching package: ‘lubridate’\n\nThe following object is masked from ‘package:base’:\n\n date\n\n\nAttaching package: ‘dplyr’\n\nThe following objects are masked from ‘package:lubridate’:\n\n intersect, setdiff, union\n\nThe following objects are masked from ‘package:stats’:\n\n filter, lag\n\nThe following objects are masked from ‘package:base’:\n\n intersect, setdiff, setequal, union\n\nError in R script my-r-function.R \n ‘subscript out of bounds’"],"stdout":"","stdoutStatus":0}

deshanm commented 5 years ago

Found the issue. I had to add an empty argument to .data() function. Example

R("example/ex-async.R")
  .data()
  .callSync(function(err, d) {
    if (err) throw err;
    console.log(d);
  });

changed to

R("example/ex-async.R")
  .data({ })
  .callSync(function(err, d) {
    if (err) throw err;
    console.log(d);
  });