Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'data' of undefined #19

Open
nikkatalnikov opened this issue May 7, 2018 · 8 comments
Open

Cannot read property 'data' of undefined #19

nikkatalnikov opened this issue May 7, 2018 · 8 comments

Comments

@nikkatalnikov
Copy link

nikkatalnikov commented May 7, 2018

This simple code

var R = require("r-script");
var fs = require("fs");

var data = fs.readFileSync('r_code/sample.xlsx')
var out = R("r_code/sample.R")
  .data(data, 20)
  .callSync();
  
console.log(out);

leads to the following error

TypeError: Cannot read property 'data' of undefined
    at Object.<anonymous> (/Users/**/Desktop/**/**/r/index.js:9:3)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Function.Module.runMain (module.js:701:10)
    at startup (bootstrap_node.js:194:16)
    at bootstrap_node.js:618:3

what am i doing wrong?

@Khamurdik
Copy link
Contributor

This bug can be solved with this pull request: #20

@MarkusKonk
Copy link

Hi,
I installed Rscript using your fork @Khamurdik as I had the same issue. However, now I get the following error. Do you not this issue? It occurs if I run an R script using .call
error

@garvk
Copy link

garvk commented May 23, 2018

pulling the #20 request, corrected the error. Thanks a lot!


Hello,

I am having the same issue, has the issue been solved?

'r-script' package is running fine for me in one project, however, when i create the same project for a new user it gives me the error : "TypeError: Cannot read property 'data' of undefined".

Is there a particular way how 'needs' package (on R) is to be installed and used for correct connection between nodejs and R ?
Please, help!

@MarkusKonk
Copy link

Btw: I am geeting the error if I use this code from your example folder:

#!/usr/bin/env node
var R = require("r-script");
// async
var attitude = JSON.parse(
  require("fs").readFileSync("attitude.json", "utf8"));
R("ex-async.R")
  .data({df: attitude, nGroups: 3, fxn: "mean" })
  .call(function(err, d) {
    if (err) throw err;
    console.log(d);
  });

@Codypinto23
Copy link

@Khamurdik and @MarkusKonk , I am also pulling the #20 request and receiving error:

TypeError: Incorrect value of args option
child_process.js:389
    at normalizeSpawnArguments (child_process.js:389:11)
    at Object.exports.spawn (child_process.js:496:38)
    at R.call (c:\Users\user\React\ExpressTest\express-test\node_modules\r-script\index.js:35:29)
    at executeBound (c:\Users\user\React\ExpressTest\express-test\node_modules\underscore\underscore.js:758:67)
    at R.<anonymous> (c:\Users\user\React\ExpressTest\express-test\node_modules\underscore\underscore.js:771:14)
    at R.call (c:\Users\user\React\ExpressTest\express-test\node_modules\underscore\underscore.js:122:29)

@MarkusKonk
Copy link

I created a very minimal working example which only runs the R file (and writes the out.Rout file) but does not pass data. For my purpose this was sufficient. Maybe it helps you: https://github.com/MarkusKonk/r-script

@Khamurdik
Copy link
Contributor

Khamurdik commented May 24, 2018 via email

@Codypinto23
Copy link

Codypinto23 commented May 24, 2018

Looks like pulling the 'fix_bindAll' branch did the trick for me! I'm no longer getting that error. Thanks so much for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants