Re: [R] Calling LISP programs in R

From: Steven McKinney <smckinney_at_bccrc.ca>
Date: Wed, 23 Jul 2008 12:40:41 -0700

Have you reviewed the old
xlisp machinery that used to
be in R? Check out the RXLisp
library at
http://www.omegahat.org/RXLisp/
and see if this will work. The
PDF
http://www.omegahat.org/RXLisp/examples.pdf reviews calling xlisp from R.

HTH Steve McKinney

-----Original Message-----
From: r-help-bounces_at_r-project.org on behalf of francogrex Sent: Wed 7/23/2008 7:06 AM
To: r-help_at_r-project.org
Subject: [R] Calling LISP programs in R  

I have written some programs in Common Lisp and I have been using SAS to pipe those programs to my lisp compiler in batch mode by using the %xlog and
%xlst SAS commands. I wonder if there is in R a similar way to pipe commands
to LISP so that all my work would be concentrated in R even when I have to call a LISP program? I have looked at the foreign library but this seems to adjust data types not for piping commands in batch mode.

Here is a simple program (example) to generate random normal variables from SAS to LISP; of course it's a toy example because there is no need for a LISP routine in this particular case. I hope R has a similar feature. Thanks DATA _NULL_;
FILE 'c:\cl.lisp' LRECL=1024;
PUT "(defun run (num Mn SD)";
PUT "(setq mix (list nil))";
PUT "(dotimes (n num)";

PUT    "(setq u (- (* 2 (random 1.0)) 1)"; 
PUT    "v (- (* 2 (random 1.0)) 1)"; 
PUT    "w (+ (expt u 2) (expt v 2)))";
PUT    "(when (< w 1)";
PUT      "(progn";
PUT        "(setq z (sqrt (/ (* -2 (log w)) w))";
PUT        "x (* u z)";
PUT        "y (* v z)";
PUT         "mix (append (list x)  mix)";
PUT         "mix (append (list y)  mix)))))";
PUT   "(setq mix (remove nil mix)";
PUT   "mixnew (loop for x in mix append (list(+ Mn (* SD x)))))";
PUT "(print mixnew)";
PUT "(flet(( mean(zlist)";
PUT     "(setq sum (loop for x in zlist sum x))";
PUT     "(setq m (/ sum (length zlist)))))";
PUT '(pprint (list "The mean is:" (mean mixnew))))'; PUT "(flet((var(zlist)";
PUT     "(setq sumsq (loop for x in zlist sum (* (- x m) (- x m)))";
PUT     "v (/ sumsq (- (length zlist) 1)))))";
PUT "(setq std (sqrt (var mixnew))))"; PUT '(pprint (list "The Standard Deviation is:" std)))'; PUT "(run 500 41 17.5)";
RUN;
%xlog(CL);
-- 
View this message in context: http://www.nabble.com/Calling-LISP-programs-in-R-tp18611512p18611512.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 23 Jul 2008 - 20:22:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jul 2008 - 20:34:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive