joshkatz / r-script

A simple little module for passing data from NodeJS to R (and back again).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error - subscript out of bounds

deshanm opened this issue · comments

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}

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);
  });