1.0.7 • Published 2 years ago

@maki-people/r-script v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago