sutharsanpk
sutharsanpk

Reputation: 1

How to use Nodejs with R to get results

I am trying to use nodejs with R, how to Execute R algorithm via Node.Js and get the results.

Upvotes: 0

Views: 1217

Answers (2)

stdob--
stdob--

Reputation: 29172

  1. Install OpenCPU && RStudio Server
  2. Install node-opencpu client
  3. Begin to use OpenCPU API

Upvotes: 0

Claudio Bredfeldt
Claudio Bredfeldt

Reputation: 1422

Check out exec, a node module to run terminal statements.

Example:

var exec = require('exec')

exec('code to run my R script', function(err, response) {
    if (err instanceof Error) throw err;

    if (err) {
        console.error('Something went wrong', err);
        process.stderr.write(err);
    }

    // R output
    console.log('All good', response);
    process.stdout.write(response);

    process.exit(1);
});

child_process is also a valid alternative. Checkout this: Run R script and display graph using node.js

Upvotes: 2

Related Questions