RSOA

From Intamap

Initiatives that may be of interest to us:

  • RApache is an R module in Apache
  • RSOAP uses Rpy (R python bindings) and Soappy in order to let R be accessed through a SOAP interface. It seems that it is not meant for communication from R to other programs or databases through SOAP. An article is listed here.
  • Rserve which provides access to R on the TCP/IP level
  • rJava is a simple R-to-Java interface
  • JRI is a Java/R Interface

R questions that have arisen at Aston (added by Lucy, please feel free to add answers and more questions!):

  • Which Java-R interfaces have INTAMAP members successfully used?
    • Working on Windows, I have only managed to get JRI working, not rJava - LB.
      • EP - try installing JGR, it will take them with it. I guess it downloads the packages directly from a different package repository, follow this link
  • On the same subject, does anyone have Windows binaries for the rJava interface?
    • These are allegedly available "on request" but I couldn't get hold of them - LB
      • same answer - EP
  • Is there any interface which will let us build a 2- or more-D array in Java and pass it to R?
    • In both rJava and JRI, it seems that you can pass data in one row at a time, and build the array or data frame inside R. It looks as though there are ambiguities with trying to populate or refer to elements with more than one dimension from Java - is this right?
      • Perhaps not the most elegant, but how about passing the array as a vector, next pass the dimensions, next in R use matrix(a, nrow, ncol) or for higher-dimensional arrays array(a, dim) as in array(1:16,c(4,2,2)) - EP
  • If we wanted to 'mask off' part of a grid inside R, to save interpolating effort, what would be the best library to use -e.g., 'sp', 'spgpc', or another? Or would we be better advised to read from file a Boolean mask array created outside R?
    • what do you have to mask them off with? A set of polygons? The overlay method in is your friend. Try this. - EP
library(sp)
# dummy data:
xy = SpatialPoints(data.frame(x=1:10,y=1:10))
grd = makegrid(xy, n = 500)
gridded(grd)=~x1+x2
plot(grd)
plot(xy, add=TRUE, col='blue')
pol=cbind(c(3,6,6,3),c(3,3,6,3))
lines(pol)
p = SpatialPolygons(list(Polygons(list(Polygon(list(pol))), "ID")))
# p will usually be imported, e.g. from a shapefile
# now select grd points in the polygon:
grdsel = grd[!is.na(overlay(grd,p))]
plot(grdsel, col = 'red', add=TRUE)