removed CLSR from master -- still in tonylocal, and need clr in tonylocal as well
[rclg.git] / old / README
blobfcdab0ca1aca17f7f7e937b621148b25aa9a5deb
1 This is an initial version of a R-to-Common-Lisp Gateway (RCLG).
2 Copyright rif 2003, 2004.
3 The code is not released.
5 Dependencies: uffi and common-idioms
7 Although the system is written mostly on top of UFFI, there're a few
8 calls to CMUCL's alien interface, so it should only work on CMUCL.
9 (The last time I checked, it also worked unchanged on SBCL).  (It's
10 impossible to obtain elements of nested structures efficiently on
11 CMUCL using UFFI --- you get enormous slowness and consing.)
13 The RCLG system (rclg.asd) automatically starts R when loaded.  If
14 your R_HOME environment variable is not set, your CL will crash.  I
15 run CL in slime, and put
17 (setenv "R_HOME" "/usr/local/lib/R")
19 in my .emacs.  A similar incantation should work depending on where R
20 is installed.  
22 Note: The current rclg-load.lisp has an explicit path to libR.so.  You
23 should probably check to make sure this path is right.
25 Note: R generates "invalid" floating point instructions.  Therefore,
26 we need to remove :invalid from floating-point-modes before starting
27 R.  This is done automatically at startup time.  Unfortunately, for
28 reasons that are not clear to me, this doesn't work under SLIME unless
29 SLIME is run with the :fd-handler communication style.
31 Once you have it up and running, the basic command to use is r.
33 For example, 
35 CL-USER> (r seq 1 5)
36 #(1 2 3 4 5)
37 NIL
38 CL-USER> (r rnorm 4)
39 #(-0.8058522483571727d0 -0.5010746712745403d0 0.30730975077719486d0
40   -0.7376820201686767d0)
41 NIL
43 Some efforts towards efficiency have been made.  The
44 array-element-types of the results are correct:
47 Note that the second value returned is the "names" associated with the
48 R object.
50 There is also a package :rclg-util, which is designed to aid in
51 defining calls to R with lots of default options.  Compare the outputs of
52 (r plot (r seq 1 5))
53 and
54 (r-plot (r seq 1 5))
56 I'm not sure why def-r-call is a macro-defining-macro rather than a
57 function defining macro.
59 Any suggestions for improvements or workarounds to all the kludges are
60 appreciated.