R
Class for accessing R via libR.
Static Member Summary
| Static Public Members | ||
| public static get |
Acquire global environment in R. |
|
| public static get |
Initialized libR object for accessing R. |
|
Static Method Summary
| Static Public Methods | ||
| public static |
Check whether R class is globally initialized or not. |
|
| public static |
Python like range function. |
|
Constructor Summary
| Public Constructor | ||
| public |
Constructor function for class R |
|
Member Summary
| Public Members | ||
| public |
[e]: * |
|
Method Summary
| Public Methods | ||
| public |
Execute R code. |
|
| public |
evalWithTry(code: string, silent: boolean): * Execute R code with R try. |
|
| public |
eval_direct(code: string): SEXPWrap Execute R code without error handling. |
|
| public |
Execute R code. |
|
| public |
Acquire bridging function to access R function. |
|
| public |
Acquire bridging function to access R function. |
|
| public |
Acquire value of R variable |
|
| public |
getVarNames(varname: string): string Acquire names attribute of R variable |
|
| public |
overrideBusy(onBusy: function) Set callback on R's computation. |
|
| public |
overrideReadConsole(onReadConsole: function) Use your own console input/output instead of R's default one. |
|
| public |
overrideShowMessage(onMessage: function) Use your own console input/output instead of R's default one. |
|
| public |
overrideWriteConsole(onWriteConsole: function) Use your own console input/output instead of R's default one. |
|
| public |
release() Finish using R. |
|
| public |
Set value to R variable |
|
| public |
setVarNames(varname: string, value: object) Set names attribute to R variable |
|
| Private Methods | ||
| private |
__RFuncBridge(func: function): * Bridging function for R function. |
|
| private |
__RFuncBridge_raw(_func: function): SEXPWrap Bridging function for R function. |
|
| private |
__eval_langsxp(langsxp: *, silent: boolean): * Execute R code with LANGSXP |
|
| private |
__func_sexp(name: string): SEXPWrap Find functions in R environment. |
|
| private |
Load some R functions. |
|
Static Public Members
Static Public Methods
Public Constructors
Public Members
public [e]: * source
Public Methods
public eval(code: string, silent: boolean): * source
Execute R code.
Return:
| * | JavaScript compatible object of returned value. |
Throw:
When execution fails. |
Example:
let value = R.eval("sum(c(1, 2, 3))") // value will be 6
public evalWithTry(code: string, silent: boolean): * source
Execute R code with R try. This is more safe than R#eval.
Return:
| * | Returned value. Returns undefined on error. |
public eval_direct(code: string): SEXPWrap source
Execute R code without error handling. App crashes when execution/parse failure. Please use this function with care.
Params:
| Name | Type | Attribute | Description |
| code | string | R code |
See:
public eval_raw(code: string, silent: boolean): SEXPWrap source
Execute R code.
Throw:
When execution fails. |
See:
- eval, R_ParseEvalString
public func(name: string): function source
Acquire bridging function to access R function. Functions receive JavaScript value, and returns JavaScript compatible objects.
Params:
| Name | Type | Attribute | Description |
| name | string | name of R function |
Example:
const sum = R.func("sum")
console.log(sum([1, 2, 3])) // prints 6
public func_raw(name: string): function source
Acquire bridging function to access R function. This function doesn't convert to/from SEXP. Receives SEXPWrap, and returns SEXPWrap. Please use carefully.
Params:
| Name | Type | Attribute | Description |
| name | string | name of R function |
See:
public getVar(varname: string): * source
Acquire value of R variable
Params:
| Name | Type | Attribute | Description |
| varname | string | Name of variable |
Return:
| * | Value in the R variable. |
public getVarNames(varname: string): string source
Acquire names attribute of R variable
Params:
| Name | Type | Attribute | Description |
| varname | string | Name of variable |
Return:
| string | Associated name attribute for the specified R variable. If no name, undefined will be returned. |
public overrideBusy(onBusy: function) source
Set callback on R's computation.
Params:
| Name | Type | Attribute | Description |
| onBusy | function | Function called on busy/job finish |
public overrideReadConsole(onReadConsole: function) source
Use your own console input/output instead of R's default one.
Params:
| Name | Type | Attribute | Description |
| onReadConsole | function | Function on console read |
public overrideShowMessage(onMessage: function) source
Use your own console input/output instead of R's default one.
Params:
| Name | Type | Attribute | Description |
| onMessage | function | Function on showing message |
public overrideWriteConsole(onWriteConsole: function) source
Use your own console input/output instead of R's default one.
Params:
| Name | Type | Attribute | Description |
| onWriteConsole | function | Function on console write |
Private Methods
private __RFuncBridge(func: function): * source
Bridging function for R function. Please do not call this function manually.
Params:
| Name | Type | Attribute | Description |
| func | function | SEXPWrap object of R function |
Return:
| * | JavaScript compatible returned value |
private __RFuncBridge_raw(_func: function): SEXPWrap source
Bridging function for R function. This bridging function doesn't handle SEXP. Please do not call this function manually.
Params:
| Name | Type | Attribute | Description |
| _func | function | SEXPWrap object of R function |
private __eval_langsxp(langsxp: *, silent: boolean): * source
Execute R code with LANGSXP
Params:
| Name | Type | Attribute | Description |
| langsxp | * | ||
| silent | boolean |
|
Return:
| * |
