USING R IN WEB SERVICES

In oceanography and fisheries we have a lot of scripts developed with R.

  • Ubuntu 14.04 Droplet with 1 GB of RAM and 1 GB of swap space or 2 GB of RAM
  • The latest version of R installed

Shiny Server is useful not only for hosting Shiny applications, but also for hosting interactive R markdown documents.

By setting up Shiny Server, we are able to host Shiny applications and interactive R documents on the web in a way that is accessible to the public.

+

+

  1. RSTATS: 

- NPM packagge

- An interface for node.js to statistical programming language R

To retrieve an object from the R session, we use the get command. For example, let us create a 2x2 matrix in R and retrieve it in JavaScript as a nested array:

R.parseEvalQ("mat = matrix(1:4,ncol=2,nrow=2)");
var mat = R.get('mat');

Internally, the get function uses JSON in order to convert the R data types to JavaScript data types.

+

2.    Execute R as external program from within node.js

var exec = require('child_process').exec;
exec('R', function callback(error, stdout, stderr){
    // result
});

- We want to use the child_process module

USING R IN WEB SERVICES

By Luis Miguel Agudo Bravo

USING R IN WEB SERVICES

  • 686