The Altair Community is migrating to a new platform to provide a better experience for you. The RapidMiner Community will merge with the Altair Community at the same time. In preparation for the migration, both communities are on read-only mode from July 15th - July 24th, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here.
Options

R Script - gridSVG

JEdwardJEdward RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 578 Unicorn
edited November 2018 in Help

Hello,

 

It's been a little while since I used R and now I've forgotten how to export plots from R as SVG/PNG so that they can easily be displayed in RM Server without me needing to write to disk.  My example code works in RStudio, but in RM gives me the cryptic error message "We shouldn't be here!"

 

Can someone take a look and see what I'm doing incorrectly?   If there's a simpler way, png is also cool.  

 

<?xml version="1.0" encoding="UTF-8"?><process version="7.3.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="7.3.000" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="r_scripting:execute_r" compatibility="7.2.000" expanded="true" height="82" name="Export a plot as an SVG" width="90" x="179" y="187">
<parameter key="script" value="# rm_main is a mandatory function, &#10;# the number of arguments has to be the number of input ports (can be none)&#10;rm_main = function()&#10;{&#10;&#9;library(ggplot2)&#10;&#9;library(gridSVG)&#10;&#9;ggplot(iris, aes(Species, Sepal.Length)) + geom_point()&#10;&#9;&#10;&#9;SVGlist &lt;- grid.export(name = NULL)&#10;&#9;str(SVGlist, 1)&#10;&#9;List of 4&#10;&#9;# $ svg :Classes 'XMLInternalElementNode', 'XMLInternalNode', 'XMLAbstractNode' &lt;externalptr&gt; &#10;&#9;# $ coords :List of 18&#10;&#9;# $ mappings:List of 5&#10;&#9;# $ utils : chr &quot;// Note that this code is documented using JSDoc and guided by the following URLs:\n// http://code.google.com/p/jsdoc-toolkit/w&quot;| _truncated__&#10;&#9;&#10;&#9;&#10;&#9;#the SVG code&#10;&#9;returnData &lt;- SVGlist$svg&#10; return(returnData)&#10;}&#10;"/>
</operator>
<operator activated="false" class="text:read_document" compatibility="7.3.000" expanded="true" height="68" name="Read Document" width="90" x="447" y="391">
<parameter key="extract_text_only" value="false"/>
</operator>
<connect from_op="Export a plot as an SVG" from_port="output 1" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>

Answers

  • Options
    Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    You actually got it an R produced image to autopopulate in a Server dashboard? That's pretty cool because that stumped me for a long time.

Sign In or Register to comment.