Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tianyishi2001/r-helper-js
Helper functions for calling R in Node.js
https://github.com/tianyishi2001/r-helper-js
Last synced: about 1 month ago
JSON representation
Helper functions for calling R in Node.js
- Host: GitHub
- URL: https://github.com/tianyishi2001/r-helper-js
- Owner: TianyiShi2001
- Created: 2020-04-12T09:28:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T03:14:04.000Z (almost 2 years ago)
- Last Synced: 2024-09-14T21:55:55.722Z (2 months ago)
- Language: TypeScript
- Size: 613 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# r-helper-js
Helper functions for calling R in Node.js
## Installation
```bash
npm i r-helper
``````typescript
import { Rcall, Rscript } from 'r-helper';
```## Demos
## `Rcall()`
Construct a R function call as a string:
```javascript
// construct R function call (as a string) without arguments
Rcall("fun")
// --> fun()// construct R function call with different primitive types"
Rcall("fun", [114, 5.14, true, false], { foo: "bar", baz: undefined })
// --> fun(114,5.14,TRUE,FALSE,foo="bar",baz=NA)// construct nested call
Rcall("foo", [1, Rcall("bar", ["two", Rcall("baz", [true])])])
// --> foo(1,bar("two",baz(TRUE)))
```### Signature of `Rcall()`
```typescript
function Rcall(Rfunction, args?: RArgs, kwargs?: RKwargs): RCall {/*...*/}
```where:
```typescript
type RCall = string; // matches /.+\(.*\)/
type RArg = string | number | boolean | undefined | RCall;
type RArgs = Array;
type RKwargs = { [k: string]: RArg };
```## `Rscript`
Make an Rscript command ready for execution in shell:
```typescript
Rscript(Rcall("foo", [1, Rcall("bar", ["two", Rcall("baz", [true])])]))
// Rscript -e 'foo(1,bar("two",baz(TRUE)))'
```