-
Notifications
You must be signed in to change notification settings - Fork 44
The software architecture of GSN allows the integration of third-party numerical packages such as Matlab, Mathematica, and more recently the R statistical package. Here we describe how to integrate and perform data analysis using R and GSN.
R is a programming language and a software package for statistical computing and analysis. R provides a range of techniques for statistical analysis such as liner and nonlinear modeling, classical statistical test, time-series analysis. The R software platform is composed of an engine that can interpret and execute R scripts or programs (in a similar way to GNU Octave or Matlab). The R engine can be invoked from the console or over the network using a TCP/IP server called Rserve. In this section, we describe how to configure the R and the Rserve server.
First, we have to install R. R is available in several platforms, depending on your platform you will have to follow specific instructions. We recommend to read the documentation from the official project website: http://www.r-project.org.
Rserve is a TCP/IP server which allows other programs to use invoke R from various languages without the need to initialize R or link against R library. Rserve can be downloaded from the following website: http://www.rforge.net/Rserve. Rserve is written in Java and it has bindings for other languages. Rserve comes as a R package, therefore, to install and run Rserve, the library and the package have to be invoked within R as follows:
user@host\# R
R version 2.6.2 (2008-02-08)
Copyright (C) 2008 The R Foundation for Statistical Computing
> library(Rserve)
> Rserve()
This will load the Rserve library and start the Rserve TCP/IP server on the localhost. The default port is 6311. To read more about how to invoke R using Rserve, please refer to the Rserve documentation website: http://www.rforge.net/Rserve.
<virtual-sensor name="plot" priority="10">
<processing-class>
<class-name>gsn.vsensor.RVirtualSensor</class-name>
<init-params>
<param name="plot">2D</param>
<param name="device">jpeg</param>
<param name="operation">x<-rnorm(10);plot(x,$temperature$);</param>
</init-params>
<output-structure>
<field name="plot" type="binary:image/jpeg"/>
</output-structure>
</processing-class>
<description>Plots a graph using R.</description>
<life-cycle pool-size="10"/>
<addressing>
<predicate key=""></predicate>
</addressing>
<storage history-size="1h"/>
<streams>
<stream name="input1">
<source alias="source1" sampling-rate="1" storage-size="1">
<address wrapper="multiformat">
<predicate key="rate">2000</predicate>
</address>
<query>SELECT temperature, timed FROM wrapper WHERE packet_type=2</query>
</source>
<query>SELECT temperature, timed FROM source1</query>
</stream>
</streams>
</virtual-sensor>