R in Wandora

From WandoraWiki
(Difference between revisions)
Jump to: navigation, search
(Installing required R libraries)
Line 23: Line 23:
 
   install.packages("igraph")
 
   install.packages("igraph")
  
Currently Wandora has an unresolved problem with the default graphics device in R in Windows environment. To be able to plot anything you will need to install the ''JavaGD'' graphics device using. This is only needed in Windows.
+
Currently Wandora has an unresolved problem with the default graphics device in R in Windows environment. To be able to plot anything in Windows you will need to install the ''JavaGD'' graphics device using. This is only needed in Windows.
  
 
   install.packages("JavaGD")
 
   install.packages("JavaGD")

Revision as of 11:45, 18 July 2011

NOTE: This is an upcoming feature which is not yet included in the release version of Wandora.

Wandora can be used with the R language. R is an environment for statistical computing and graphing. Properties of the topic map and its topics can be accessed from R and statistics and graphs can be generated from them.

Contents

Setting up R

To use R in Wandora you need to install R, then install a few R libraries using the package manager inside R and finally possibly adjust some environment parameters in the Wandora startup script. These steps are explained in detail below.

Installing R

Download R from the R website at http://www.r-project.org/ and follow the installation instructions there.

On Linux environments R may also be available using the package repository of your Linux distribution. In Ubuntu the name of the package you need is r-base.

Installing required R libraries

At the very least you must install the rJava library. Do this using the package manager inside R. First run R using the administrator account. On Windows right click the icon and select "Run as Administrator". On Linux run R from console using "sudo R". Then issue the command

 install.packages("rJava")

Most likely you will also want to install the igraph library. It is needed to plot network graphs. To do this issue the command

 install.packages("igraph")

Currently Wandora has an unresolved problem with the default graphics device in R in Windows environment. To be able to plot anything in Windows you will need to install the JavaGD graphics device using. This is only needed in Windows.

 install.packages("JavaGD")

Setting up enviroment variables

Next make sure that the environment variables are setup correctly in the Wandora startup script. On Windows open the bin/SetR.bat file and on Linux the bin/SetR.sh file. If you did a standard installation of R then the Linux start-up script likely needs no changes at all.

The Windows start-up script however has two things that may need adjusting. Make sure the first line points to you R installation directory. Especially the R version number may need to be changed. Also make sure that the processor architecture matches your Java installation. Note that you may have a 32-bit Java even if your system is 64-bit. If you aren't sure which Java you have you can simply try both settings and see which one works. The architecture is specified on lines 5 and 6. For 32-bit use

 set R_ARCH=i386
 REM set R_ARCH=x64

And for 64-bit

 REM set R_ARCH=i386
 set R_ARCH=x64

Other parameters should be correct unless you have customized your R installation beyond standard setup.

You should now be able to use R inside Wandora.

Plotting in Windows

The default graphics device doesn't work correctly in Windows. If you try to plot anything you will get an unresponsive graphics window. If at any time you accidentally open it you can close it cleanly in Wandora R Console with

 dev.off()

To work around this issue you need to use the JavaGD graphics device. You first need to load the JavaGD library with

 library("JavaGD")

Then initialize the graphics device with

 JavaGD()

This will open an empty graphics window. You can then use plot normally to plot in this window.

Examples

Personal tools