R Action Blocks

Aus expecco Wiki (Version 2.x)
Zur Navigation springen Zur Suche springen

Introduction[Bearbeiten]

With expecco18.1, another new block type is introduced: "R Actions". These behave similar to other script action blocks, in that they are defined by a script (in this case: R script language) and are placed into the test sequence flow just like any other block.

Similar to the plot/graph (gnu plot) actions, these may generate a graphic document (jpeg, png or postscript), which can be added to the activity log, or added as attachment. The graphic (and possibly other output data) will therefore be available in the generated "elf" execution log file, and/or shown in the generated "pdf" report file. Of course, you can do anything you like with the generated graphic file, by feeding the name of the generated file to another action for further processing.

Creating R Script Action Blocks[Bearbeiten]

Script action blocks are created via the "Actions - More - R Action" menu item.

Select the "R Action" item, to create a new R action. An initial set of input pins and an initial (demo-) script is generated for you.

For details on the scripting language, please refer to the public R documentation "http://www.gnuplot.info/docs_5.0/gnuplot.pdf" or take a look at "https://en.wikipedia.org/wiki/R_(programming_language)".

Any input pin named "<pinName>" is available in the script as "%(pinName)". Thus, the script can be parametrized in arbitrary ways. A number of pins are already created for you; these are:

  • "stdout"
    the standard output (if any) as generated by the script
  • "stderr"
    the standard error (if any) as generated by the script
  • "data"
    If connected, and a collection of values is present, these values will be written into a temporary data file, and the filename is available in the gnuplot script as "%(data)". Theis will be the raw data, to be processed by the script.
  • "dataSize"
    There is no pin for that, but the value is available to the script. It provides the number of data points (or rows) in the data file.

A Simple R Script (which also generates a Plot)[Bearbeiten]

A typical gnuplot script looks like:

jpeg( "%(imageFile)" ) barplot(table(sample(1:3, size=1000, replace=TRUE, prob=c(.30,.60,.10)))) dev.off

where imageFile is an input pin, which provides the name of the generated jpeg file.

Accessing Data from Attachments[Bearbeiten]

You can directly access expecco attachment files by their name inside the script. I.e. if you have an attachment with filename "foo.dat", use ... data "foo.dat" ... inside the script. Notice that the attchment's filename is to be used - not its name in the tree.

Caveats[Bearbeiten]

Do not place pause statements into the script; there is no input stream given to R, so it will immediately read an EOF (end of file) and proceed.



Copyright © 2014-2024 eXept Software AG