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 fix would be to replace the first Merge with an RShell code to call deparse().
The first Merge 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 the input depth is 1 but the input port depth is 2.
The second Merge creates a comma-separated list of the deparsed R expressions.
The wrap_in_list component 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 wrap_in_list actually outputs a 1-element list containing the string.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (1)
Convert Taverna list of RExpr to R list |
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 fix would be to replace the first Merge with an RShell code to call deparse().
The first Merge 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 the input depth is 1 but the input port depth is 2.
The second Merge creates a comma-separated list of the deparsed R expressions.
The wrap_in_list component 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 wrap_in_list actually outputs a 1-element list containing the string.
|
Dependencies (0)
Inputs (1)
Name |
Description |
list_of_r_expressions |
|
Processors (4)
Name |
Type |
Description |
Merge_RExpr_List_to_a_String_List |
localworker |
ScriptString seperatorString = "\n";
if (seperator != void) {
seperatorString = seperator;
}
StringBuffer sb = new StringBuffer();
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
sb.append(item);
if (i.hasNext()) {
sb.append(seperatorString);
}
}
concatenated = sb.toString();
|
Merge_String_List_to_a_String |
localworker |
ScriptString seperatorString = "\n";
if (seperator != void) {
seperatorString = seperator;
}
StringBuffer sb = new StringBuffer();
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
sb.append(item);
if (i.hasNext()) {
sb.append(seperatorString);
}
}
concatenated = sb.toString();
|
sep |
stringconstant |
Value, |
wrap_in_list |
localworker |
ScriptList output = new ArrayList(1);
String s2 = "list(" + s1 + ")";
output.add(s2); |
Outputs (1)
Name |
Description |
r_list_of_expressions |
|
Datalinks (5)
Source |
Sink |
list_of_r_expressions |
Merge_RExpr_List_to_a_String_List:stringlist |
Merge_RExpr_List_to_a_String_List:concatenated |
Merge_String_List_to_a_String:stringlist |
sep:value |
Merge_String_List_to_a_String:seperator |
Merge_String_List_to_a_String:concatenated |
wrap_in_list:s1 |
wrap_in_list:output |
r_list_of_expressions |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1 (earliest)
(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