Skip to content

How to use R inside Scheme/Lisp

May 7, 2013

Rlogochicken-small Since being convinced by Dr. Kevin Korb of Monash Uni to consider the merits of Bayesianism, I had to do some trip back to my stats. Naturally the statistical package R comes into the picture. I kinda like this tool – firstly it is not just a static package really, it is indeed a programming language and that spells lots of interesting and creative possibilities. Then it is based on Scheme/Lisp. The authors said that Scheme influenced the development of R.

I think the interface will be a lot of fun.

Below I will document the steps to install and use R within Scheme. The Scheme version that supports this is  Chicken Scheme.

Before jumping in, I wish to acknowledge the help by and thank Mr. Peter Danenberg aka “klutometis”,  the author of the R scm code, for his contribution to the Scheme and R user communities.

Here I am using Mac Os X, Lion.

1. Check that you have the Xcode tool set, then see to it that you install the command line tools.

2. See to it that you got Macports installed. Choose your OS X version from the site. You will use this to download Chicken Scheme.

3. When Macports finished installing see to it that you do

sudo port selfupdate

4. Now install chicken

sudo port install chicken

5. Make sure you install cock as well as cock-utils for documentation of Chicken Scheme. Do this

sudo chicken-install cock


sudo chicken-install cock-utils

5. Now install R interface (note– I assume you have already installed R proper even before we got to step 1 above).

sudo chicken-install R

You will get a segfault but ignore this. See picture, click to view. Sorry for the lack of scale, I have no time to make it pretty right now.











6. Run csi (the interactive REPL of Chicken Scheme) then issue (use R), within the REPL. Libraries will be loaded and in the end you will get a warning about R_HOME not being set, ignore this or set it. You are done. You can now use R within Scheme. See what R stuff you can issue within Scheme by clicking here.

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: