9.7. NeoOfficeJ and OpenOffice

 < Day Day Up > 

9.6. R with an Aqua GUI

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, R.app, has been developed by Stefano M. Iacus and others associated with the R-Core/R-Foundation. A binary distribution of R for Mac OS X, among other systems, is distributed through the Comprehensive R Network (CRAN; http://cran.r-project.org/).

The installer places an application named R in your Applications folder. Double-clicking the R icon opens an Aqua-based console window, in which you enter R commands as shown in Figure 9-15.

Figure 9-15. The R Console

Figure 9-16 shows an R graphics window containing a histogram.

R is also AppleScriptable. Example 9-1 shows an AppleScript that instructs R 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 R console or from a Terminal (or xterm) window. To use X11 graphics from the R console, you must first click the X icon in the R Console's toolbar to start the X11 Window server. If, on the other hand, you start R from the Terminal, you'll need to start X11 before displaying graphics in an X11 window. Figure 9-17 shows the same histogram shown in Figure 9-16, but this time it's displayed in an X11 window.

Figure 9-16. R's graphics window

Figure 9-17. R graphics, X11 style

Example 9-1. AppleScript to interact with R
 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-2.01, which was available at the time of this writing. Be sure to consult the CRAN web site for up-to-date information.

     < Day Day Up > 

    Mac OS X Tiger for Unix Geeks
    Mac OS X Tiger for Unix Geeks
    ISBN: 0596009127
    EAN: 2147483647
    Year: 2006
    Pages: 176

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