Interface to R
Although it has greatly improved since the Zoomgraph implementation, the connection to R is still in the process of being defined. GUESS, like Zoomgraph, makes use of the Rserve to connect to R. The program is very easy to install for both windows and Unix distributions (see:
http://stats.math.uni-augsburg.de/Rserve/).
Once you have Rserve installed, start it up. By default GUESS will attempt to connect to the local machine’s Rserve process. If you are running R somewhere else you will want to execute the command r.initConnection(“host”) where host is the host to connect to.
There are two main interfaces to R through GUESS. The first allows us to set variables inside the R environment and pull back values. The second, an “R mode,” reroutes every command typed in GUESS directly to R. Note that at present this mode is only available for the command line version (not the GUI version) of the interpreter.
To set variables in R, we use the syntax: r.variable_name = value. For example, r.x = 5 will set a variable called x in the R space to 5. You may also pass double and integer arrays and double arrays to R in this way. To extract variables from R, you would use r.variable_name. For example:
r.x = 5 r.y = 4 foo = r.x – r.y
Will set two variables in the R space to 5 and 4, and will then set the value of foo (in GUESS) to be the difference between them (1.0). Beyond simple variables and arrays, the command r.graph = g will set the graph variable in R to a matrix corresponding to the GUESS graph.
If you would like to invoke R commands you would tell GUESS to go into the “R mode” by typing rmode. You will notice that the prompt will change to “R>” to leave this mode simply type a period by itself on a line and press enter (i.e. “.”). Note that unless the R connection is broken you will be able to switch in and out of R mode without losing data. When in R mode you will be able to execute whatever R commands you like. A new feature of GUESS is that plots are rendered to a file that is then displayed in GUESS. For example, try this:
r.graph = g rmode library(sna) gplot(graph)
In this mode you will be able to do whatever analysis you want. In order to pull data back into GUESS simply set some variable to the data you want to retrieve, exit R mode and use the “r.variable_name” syntax to pull the data back. A simple example would be:
rmode z<-500 . r.z
This sequence of commands would set the value of z to 500 in R and then retrieve that value in GUESS.


