Skip to content

ffittschen/node-call-rscript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-call-rscript

Call Rscripts from node.js passing JSON both ways.

Install

yarn add https://github.com/ffittschen/node-call-rscript

Usage

const R = require('node-call-rscript');

// Sync
R.callSync('path/to/Rscript.R', [Args]);

// Async using Promises
R.call('path/to/Rscript.R', [Args]);

Synchronous

const result = R.callSync('./test.R', {
  a: 1,
  b: 3,
});
console.log(result);

Asynchronous

R.call('./test.R', {
  a: 1,
  b: 3,
}).then((result) => {
  console.log(result);
}).catch((error) => {
  console.log('error = ', error);
});

R script template

The node-call-rscript module tries to parse the whole stdout body from the R script as JSON. Therefore it is suggested to follow the Template, capture all stdout from the script and only print the JSON that should be returned to the JavaScript code.

Example

yarn test

About

Call Rscripts from node.js passing JSON both ways.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published