Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rksm/lively-r-evaluate

Providing support for R code evaluation from Lively Web.
https://github.com/rksm/lively-r-evaluate

Last synced: about 1 month ago
JSON representation

Providing support for R code evaluation from Lively Web.

Awesome Lists containing this project

README

        

lively-R-evaluate

body, td {
font-family: sans-serif;
background-color: white;
font-size: 12px;
margin: 8px;
}

tt, code, pre {
font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace;
}

h1 {
font-size:2.2em;
}

h2 {
font-size:1.8em;
}

h3 {
font-size:1.4em;
}

h4 {
font-size:1.0em;
}

h5 {
font-size:0.9em;
}

h6 {
font-size:0.8em;
}

a:visited {
color: rgb(50%, 0%, 50%);
}

pre {
margin-top: 0;
max-width: 95%;
border: 1px solid #ccc;
white-space: pre-wrap;
}

pre code {
display: block; padding: 0.5em;
}

code.r, code.cpp {
background-color: #F8F8F8;
}

table, td, th {
border: none;
}

blockquote {
color:#666666;
margin:0;
padding-left: 1em;
border-left: 0.5em #EEE solid;
}

hr {
height: 0px;
border-bottom: none;
border-top-width: thin;
border-top-style: dotted;
border-top-color: #999999;
}

@media print {
* {
background: transparent !important;
color: black !important;
filter:none !important;
-ms-filter: none !important;
}

body {
font-size:12pt;
max-width:100%;
}

a, a:visited {
text-decoration: underline;
}

hr {
visibility: hidden;
page-break-before: always;
}

pre, blockquote {
padding-right: 1em;
page-break-inside: avoid;
}

tr, img {
page-break-inside: avoid;
}

img {
max-width: 100% !important;
}

@page :left {
margin: 15mm 20mm 15mm 10mm;
}

@page :right {
margin: 15mm 10mm 15mm 20mm;
}

p, h2, h3 {
orphans: 3; widows: 3;
}

h2, h3 {
page-break-after: avoid;
}
}

lively-R-evaluate

lively-R-evaluate provides support for R code evaluation for Lively Kernel / Lively Web.
It defines the R API that is called by the Lively RServer.

API

evaluate(id, sourceString)

Start a new evaluation under the given id.

Arguments


  • id - String to identify the evaluation process

  • sourceString - source code to evaluate

Example

require(LivelyREvaluate)

evaluate('test', '1+4')
# evaluation happens in asynchronously in subprocess, so wait a bit
Sys.sleep(0.2)
getEvalResult('test')

The evaluation result will the be a pairlist with the fields:


  • interrupted=c(TRUE,FALSE)

  • processState=c("DONE","PENDING","NONEXISTANT")

  • result=

expr
source
value
text
graphics
message
warning
error

1
message(“hello!”)
<NA>
<NA>
<NA>
simpleMessage in message(“hello!”): hello!
<NA>
<NA>

2
1+4
5
<NA>
<NA>
<NA>
<NA>
<NA>

evaluateToJSON(json)

Call evaluate by specifying id and source with JSON and return the result as JSON

Arguments


  • json - {id: STRING, source: STRING}

stopEvaluation(id)

Interrupts an evaluation process.

Arguments


  • id - The process name/identifier (id given by user, not pid!)

getEvalResult(id)

Returns the evaluation result.

Arguments


  • id - The eval identifier

Example

See evaluate()

getEvalResults()

Returns all evaluation results.

License

MIT license