Convert Taverna list of RExpr to R list - v2
Created: 2013-09-04 15:37:15
Last updated: 2013-10-14 15:41:25
This workflow accepts a Taverna list of arbitrary R expressions and returns a single R expression representing an R list containing the original expressions.
This workflow relies on the current Taverna behaviour of an R expression being represented by a list of strings containing the deparsed expression. If this changes, this workflow will likely break.
The first BeanShell converts each R expression (actually a list of strings) to a single string. This uses implicit iteration to do this for each R expression, so input port depth is 2 but the BeanShell input depth is 1.
The second Beanshell creates a comma-separated list of the deparsed R expressions and wraps the string with the R list() function. So now we have a single string s that can be turned into an R list using eval(parse(text=s)).
But RShell already does that parsing for us, so we just need to ensure the string looks like an R expression by turning it into a list of strings. So we actually output a 1-element list containing the string.
Version 1: initial implementation
Version 2: reduce number of BeanShells
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (1)
Convert Taverna list of RExpr to R list - v2 |
Descriptions (1)
This workflow accepts a Taverna list of arbitrary R expressions and returns a single R expression representing an R list containing the original expressions.
This workflow relies on the current Taverna behaviour of an R expression being represented by a list of strings containing the deparsed expression. If this changes, this workflow will likely break.
The first BeanShell converts each R expression (actually a list of strings) to a single string. This uses implicit iteration to do this for each R expression, so input port depth is 2 but the BeanShell input depth is 1.
The second Beanshell creates a comma-separated list of the deparsed R expressions and wraps the string with the R list() function. So now we have a single string s that can be turned into an R list using eval(parse(text=s)).
But RShell already does that parsing for us, so we just need to ensure the string looks like an R expression by turning it into a list of strings. So we actually output a 1-element list containing the string.
Version 1: initial implementation
Version 2: reduce number of BeanShells
|
Dependencies (0)
Inputs (1)
Name |
Description |
list_of_r_expressions |
|
Processors (2)
Name |
Type |
Description |
FlattenListOfStringsToString |
localworker |
ScriptStringBuffer sb = new StringBuffer();
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
sb.append(item);
if (i.hasNext()) {
sb.append("\n");
}
}
concatenated = sb.toString();
|
CombineListOfStringsIntoRList |
localworker |
ScriptStringBuffer sb = new StringBuffer("list(");
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
sb.append(item);
if (i.hasNext()) {
sb.append(",");
}
}
sb.append(")");
concatenated = sb.toString();
List output = new ArrayList(1);
output.add(sb.toString());
|
Outputs (1)
Name |
Description |
r_list_of_expressions |
|
Datalinks (3)
Source |
Sink |
list_of_r_expressions |
FlattenListOfStringsToString:stringlist |
FlattenListOfStringsToString:concatenated |
CombineListOfStringsIntoRList:stringlist |
CombineListOfStringsIntoRList:output |
r_list_of_expressions |
Uploader
License
All versions of this Workflow are
licensed under:
Version 2 (latest)
(of 2)
Credits (2)
(People/Groups)
Attributions (0)
(Workflows/Files)
None
Shared with Groups (0)
None
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment