7.6 RAqua

The open source statistical computing package R is a GNU project to develop a package similar to Bell Laboratories' S statistical package. R runs on a variety of platforms, including most X11-based systems and Windows . Although an X11-based version of R can be installed with Fink, another port of R that supports both X11 and Mac OS X, RAqua, has been developed by Stefano M. Iacus and others associated with the R-Core/R-Foundation. A binary distribution of RAqua is distributed through the Comprehensive R Network (CRAN; http://cran.r-project.org/).

The installer places an application named StartR in your Applications folder. Double-clicking the StartR icon opens an Aqua-based console window, which is divided into lower and upper subwindows. You can enter R commands in the lower subwindow, while the upper subwindow shows your command history, as shown in Figure 7-14.

Figure 7-14. RAqua's console
figs/mug2_0714.gif

Figure 7-15 shows an RAqua graphics window containing a histogram.

Figure 7-15. RAqua's graphics window
figs/mug2_0715.gif

RAqua is AppleScriptable. Example 7-1 shows an AppleScript that instructs RAqua to store some values in a variable x , and display a histogram corresponding to these values.

You can use X11 graphics with R from the Aqua R console or from a Terminal (or xterm ) window. In either case you must start X11 before starting R. To use X11 graphics from the R console, you must first start X11. If you prefer to start R from the Terminal (or xterm ), you should make a symbolic link in /usr/local/bin and add this to your path before entering R at the command line:

 sudo ln -s /Applications/StartR.app/RAqua.app/Contents/ /usr/local/lib/R sudo ln /Applications/StartR.app/RAqua.app/Contents/MacOS/R /usr/local/bin/R 

In this case, the xterm window is used to enter R commands, and the graphics are displayed using X11. Figure 7-16 shows the same histogram shown in Figure 7-15, but this time it's displayed in an X11 window.

Figure 7-16. R graphics, X11 style
figs/mug2_0716.gif
Example 7-1. AppleScript to interact with RAqua
 try      tell application "RAqua"     activate          with timeout of 1000 seconds             cmd "x = c(77, 79, 90, 69, 75, 73, 71, 69, 84)"             cmd "hist(x)"             cmd "hist(x,probability=TRUE)"             cmd "rug(jitter(x))"         end timeout     end tell end try 

We have presented a situation that corresponds to Release R-1.81, which was available at the time of this writing. Be sure to consult the CRAN web site for up-to-date information.



Mac OS X Panther for Unix Geeks
Mac OS X Panther for Unix Geeks
ISBN: 0596006071
EAN: 2147483647
Year: 2003
Pages: 212

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net