{{ message }}

# kcrt / libr-bridge

Use R from JavaScript(Node)

## Files

Failed to load latest commit information.
Type
Name
Commit time

# libr-bridge

Bridging module: JavaScript < - > R

## Sorry! It's under development.

• Some important features including S3/S4 object handling and expression are not supported yet!
• Incompatible API changes may be held.
• Please do not use in the production environment until specifications are fixed.
• Pull requests are always welcome.

## What is libr-bridge?

libr-bridge is a very powerful npm package which enables you to use R function/statistical method in Node.js environment.

R (The R Foundation, Vienna, Austria) is a free software environment for statistical computing. With libr-bridge, you can use function in R as if they were JavaScript native function.

## How to Use

Following samples and libr-bridge are written with ECMAScript 6 modules syntex (import/export). Please use esm or --experimental-modules.

```let r = new R();

const arrA = [1.00, 3.36, 8.01, 1.22, 3.74, 2.43, 7.95, 8.32, 7.45, 4.36];
const arrB = [1.04, 3.65, 6.82, 1.46, 2.70, 2.49, 7.48, 8.28, 8.93, 5.63];

console.log("Mean of arrA: " + r.mean(arrA));
console.log("Mean of arrB: " + r.mean(arrB));
console.log("Peason's correlation coefficient: " + r.cor(arrA, arrB));

/* You can pass data to R */
r.setVar("a", arrA);

/* And data can be used in R */
console.log(r.eval('sum(a)'));
r.eval('b <- a / 2');
console.log(r.eval('b'));

/* You can receive data from R */
let b = r.getVar("b");

/* Execute complex command with eval. */
r.eval(`
myfactorial <- function(x) {
if (x == 0) {
return(1)
} else {
return(x * myfactorial(x - 1))
}
}
`);
let factorial_50 = r.func("myfactorial")(50);
console.log(factorial_50);

console.log(r.eval("iris"));```

## My TODO list

• Factor
• Dataframe
• Console handling
• S3 class
• S4 class
• Graphic handling

## Author information

Programmed by kcrt (TAKAHASHI, Kyohei) http://profile.kcrt.net/

``````Copyright © 2017 kcrt (TAKAHASHI, Kyohei)
``````

## Reference

### English

1. R Internals
• You can buy Physical copy of this material. Especially recommended!
4. Rccp: Seamless R anc C++ Integration
5. Rcpp documentation
6. Rcpp for everyone (Masaki E. Tsuda)

### Japanese

Use R from JavaScript(Node)

## Releases

No releases published

## Packages 0

No packages published

•
•

## Languages

You can’t perform that action at this time.