@maki-people/r-script
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

r-script

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

Data passed from node is converted into a list and loaded into the R environment as the variable input. No special syntax in R is needed. For better portability/reliability, it's recommended to load packages with needs (comes packaged inside the module — no installation required).

Installation

npm install @maki-people/r-script

How to use

npx ts-node example/ex.ts

// [ { group: '(40,55]', rating: 46.7143, advance: 41.1429 },
//   { group: '(55,70]', rating: 64.6154, advance: 41.9231 },
//   { group: '(70,85]', rating: 77.2, advance: 45.5 } ]

Build

npm run build

Test

npm run test

Syntax

R(path)

Creates an instance of the R class that will source the R script specified by path.

R.data(...)

Adds data to the object. You can give any number of arguments of different types.

R.execute(timeout)

Calls R. Any previously supplied data is stringified into JSON and passed to R, where it's converted into a list and loaded into the R environment as the variable input. The promise resolves the R script output or reject any error. If any timeout in ms is provided, the R script process will be killed after the timeout delay.

Readme

Keywords

Package Sidebar

Install

npm i @maki-people/r-script

Weekly Downloads

431

Version

1.0.7

License

MIT

Unpacked Size

43.5 kB

Total Files

19

Last publish

Collaborators

  • gauthierd-
  • jduval