Class: WebR
WebR.WebR
The webR class is used to initialize and interact with the webR system.
Start webR by constructing an instance of the WebR class, optionally passing an options argument of type WebROptions. WebR will begin to download and start a version of R built for WebAssembly in a worker thread.
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new WebR(options?): WebR
Parameters
| Name | Type |
|---|---|
options |
WebROptions |
Returns
Defined in
webR/webr-main.ts:277
Properties
FS
• FS: Object
Type declaration
| Name | Type |
|---|---|
analyzePath |
(path: string, dontResolveLastLink?: boolean) => Promise<FSAnalyzeInfo> |
lookupPath |
(path: string) => Promise<FSNode> |
mkdir |
(path: string) => Promise<FSNode> |
mount |
<T>(type: T, options: FSMountOptions<T>, mountpoint: string) => Promise<void> |
readFile |
(path: string, flags?: string) => Promise<Uint8Array> |
rename |
(oldpath: string, newpath: string) => Promise<void> |
rmdir |
(path: string) => Promise<void> |
syncfs |
(populate: boolean) => Promise<void> |
unlink |
(path: string) => Promise<void> |
unmount |
(mountpoint: string) => Promise<void> |
writeFile |
(path: string, data: ArrayBufferView, flags?: string) => Promise<void> |
Defined in
webR/webr-main.ts:576
RCall
• RCall: ProxyConstructor<typeof RCall, RCall>
Defined in
webR/webr-main.ts:264
RCharacter
• RCharacter: ProxyConstructor<typeof RCharacter, RCharacter>
Defined in
webR/webr-main.ts:255
RComplex
• RComplex: ProxyConstructor<typeof RComplex, RComplex>
Defined in
webR/webr-main.ts:256
RDataFrame
• RDataFrame: ProxyConstructor<typeof RDataFrame, RDataFrame>
Defined in
webR/webr-main.ts:259
RDouble
• RDouble: ProxyConstructor<typeof RDouble, RDouble>
Defined in
webR/webr-main.ts:254
REnvironment
• REnvironment: ProxyConstructor<typeof REnvironment, REnvironment>
Defined in
webR/webr-main.ts:261
RInteger
• RInteger: ProxyConstructor<typeof RInteger, RInteger>
Defined in
webR/webr-main.ts:253
RList
• RList: ProxyConstructor<typeof RList, RList>
Defined in
webR/webr-main.ts:258
RLogical
• RLogical: ProxyConstructor<typeof RLogical, RLogical>
Defined in
webR/webr-main.ts:252
RObject
• RObject: ProxyConstructor<typeof RObject, RObject>
Defined in
webR/webr-main.ts:251
RPairlist
• RPairlist: ProxyConstructor<typeof RPairlist, RPairlist>
Defined in
webR/webr-main.ts:260
RRaw
• RRaw: ProxyConstructor<typeof RRaw, RRaw>
Defined in
webR/webr-main.ts:257
RString
• RString: ProxyConstructor<typeof RString, RString>
Defined in
webR/webr-main.ts:263
RSymbol
• RSymbol: ProxyConstructor<typeof RSymbol, RSymbol>
Defined in
webR/webr-main.ts:262
Shelter
• Shelter: () => Promise<Shelter>
Type declaration
• new Shelter(): Promise<Shelter>
Returns
Promise<Shelter>
Defined in
webR/webr-main.ts:275
globalShelter
• globalShelter: Shelter
Defined in
webR/webr-main.ts:247
objs
• objs: Object
Type declaration
| Name | Type |
|---|---|
baseEnv |
REnvironment |
false |
RLogical |
globalEnv |
REnvironment |
na |
RLogical |
null |
RNull |
true |
RLogical |
Defined in
webR/webr-main.ts:266
version
• version: string = WEBR_VERSION
Defined in
webR/webr-main.ts:248
versionR
• versionR: string = R_VERSION
Defined in
webR/webr-main.ts:249
Methods
close
▸ close(): void
Close the communication channel between the main thread and the worker thread cleanly. Once this has been executed, webR will be unable to continue.
Returns
void
Defined in
webR/webr-main.ts:403
destroy
▸ destroy(x): Promise<void>
Destroy an R object reference.
Parameters
| Name | Type | Description |
|---|---|---|
x |
RObject |
An R object reference. |
Returns
Promise<void>
Defined in
webR/webr-main.ts:480
evalR
▸ evalR(code, options?): Promise<RObject>
Evaluate the given R code.
Stream outputs and any conditions raised during execution are written to the JavaScript console.
Parameters
| Name | Type | Description |
|---|---|---|
code |
string |
The R code to evaluate. |
options? |
EvalROptions |
Options for the execution environment. |
Returns
Promise<RObject>
The result of the computation.
Defined in
webR/webr-main.ts:493
evalRBoolean
▸ evalRBoolean(code, options?): Promise<boolean>
Evaluate the given R code, returning a promise for a boolean value. If the returned R value is not a boolean, an error will be thrown.
Parameters
| Name | Type | Description |
|---|---|---|
code |
string |
The R code to evaluate. |
options? |
EvalROptions |
Options for the execution environment. |
Returns
Promise<boolean>
The result of the computation.
Defined in
webR/webr-main.ts:513
evalRNumber
▸ evalRNumber(code, options?): Promise<number>
Evaluate the given R code, returning a promise for a number. If the returned R value is not a number, an error will be thrown.
Parameters
| Name | Type | Description |
|---|---|---|
code |
string |
The R code to evaluate. |
options? |
EvalROptions |
Options for the execution environment. |
Returns
Promise<number>
The result of the computation.
Defined in
webR/webr-main.ts:523
evalRRaw
▸ evalRRaw(code, outputType, options?): Promise<void>
Evaluate the given R code, returning the result as a raw JavaScript object.
Parameters
| Name | Type | Description |
|---|---|---|
code |
string |
The R code to evaluate. |
outputType |
"void" |
JavaScript type to return the result as. |
options? |
EvalROptions |
Options for the execution environment. |
Returns
Promise<void>
The result of the computation.
Defined in
webR/webr-main.ts:544
▸ evalRRaw(code, outputType, options?): Promise<boolean>
Parameters
| Name | Type |
|---|---|
code |
string |
outputType |
"boolean" |
options? |
EvalROptions |
Returns
Promise<boolean>
Defined in
webR/webr-main.ts:545
▸ evalRRaw(code, outputType, options?): Promise<boolean[]>
Parameters
| Name | Type |
|---|---|
code |
string |
outputType |
"boolean[]" |
options? |
EvalROptions |
Returns
Promise<boolean[]>
Defined in
webR/webr-main.ts:546
▸ evalRRaw(code, outputType, options?): Promise<number>
Parameters
| Name | Type |
|---|---|
code |
string |
outputType |
"number" |
options? |
EvalROptions |
Returns
Promise<number>
Defined in
webR/webr-main.ts:547
▸ evalRRaw(code, outputType, options?): Promise<number[]>
Parameters
| Name | Type |
|---|---|
code |
string |
outputType |
"number[]" |
options? |
EvalROptions |
Returns
Promise<number[]>
Defined in
webR/webr-main.ts:548
▸ evalRRaw(code, outputType, options?): Promise<string>
Parameters
| Name | Type |
|---|---|
code |
string |
outputType |
"string" |
options? |
EvalROptions |
Returns
Promise<string>
Defined in
webR/webr-main.ts:549
▸ evalRRaw(code, outputType, options?): Promise<string[]>
Parameters
| Name | Type |
|---|---|
code |
string |
outputType |
"string[]" |
options? |
EvalROptions |
Returns
Promise<string[]>
Defined in
webR/webr-main.ts:550
evalRString
▸ evalRString(code, options?): Promise<string>
Evaluate the given R code, returning a promise for a string. If the returned R value is not a string, an error will be thrown.
Parameters
| Name | Type | Description |
|---|---|---|
code |
string |
The R code to evaluate. |
options? |
EvalROptions |
Options for the execution environment. |
Returns
Promise<string>
The result of the computation.
Defined in
webR/webr-main.ts:533
evalRVoid
▸ evalRVoid(code, options?): Promise<void>
Evaluate the given R code, returning a promise for no return data.
Parameters
| Name | Type | Description |
|---|---|---|
code |
string |
The R code to evaluate. |
options? |
EvalROptions |
Options for the execution environment. |
Returns
Promise<void>
A promise which fires when the R code completes, but returns no data.
Defined in
webR/webr-main.ts:503
flush
▸ flush(): Promise<Message[]>
Flush the output queue in the communication channel and return all output messages.
Returns
Promise<Message[]>
The output messages
Defined in
webR/webr-main.ts:434
init
▸ init(): Promise<unknown>
Returns
Promise<unknown>
A promise that resolves once webR has been initialised.
Defined in
webR/webr-main.ts:328
installPackages
▸ installPackages(packages, options?): Promise<void>
Install a list of R packages from Wasm binary package repositories.
Parameters
| Name | Type | Description |
|---|---|---|
packages |
string | string[] |
An string or array of strings containing R package names. |
options? |
InstallPackagesOptions |
Options to be used when installing webR packages. |
Returns
Promise<void>
Defined in
webR/webr-main.ts:466
interrupt
▸ interrupt(): void
Attempt to interrupt a running R computation.
Returns
void
Defined in
webR/webr-main.ts:455
invokeWasmFunction
▸ invokeWasmFunction(ptr, ...args): Promise<number>
Parameters
| Name | Type |
|---|---|
ptr |
number |
...args |
number[] |
Returns
Promise<number>
Defined in
webR/webr-main.ts:567
read
▸ read(): Promise<Message>
Read from the communication channel and return an output message.
Returns
Promise<Message>
The output message
Defined in
webR/webr-main.ts:411
stream
▸ stream(): AsyncGenerator<Message, void, unknown>
Stream output messages from the communication channel via an async generator.
Returns
AsyncGenerator<Message, void, unknown>
Yields
Output messages from the communication channel.
Defined in
webR/webr-main.ts:419
write
▸ write(msg): void
Send a message to the communication channel input queue.
Parameters
| Name | Type | Description |
|---|---|---|
msg |
Message |
Message to be added to the input queue. |
Returns
void
Defined in
webR/webr-main.ts:442
writeConsole
▸ writeConsole(input): void
Send a line of standard input to the communication channel input queue.
Parameters
| Name | Type | Description |
|---|---|---|
input |
string |
Message to be added to the input queue. |
Returns
void
Defined in
webR/webr-main.ts:450