Skip to content

RProjectConnector is a library providing a binding between Pharo and R

License

Notifications You must be signed in to change notification settings

NicolasAnquetil/RProjectConnector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RProjectConnector

RProjectConnector is a library providing a binding between Pharo and R. It was recovered from a SmalltalkHub project with the same name created by Vincent Blondeau.

❗ BEWARE THAT THIS IS A VERY OLD PROJECT RELYING ON USING C LIBS IN PHARO : DON"T EXPECT IT TO WORK ON NEW PHARO WITHOUT WORK, IT WON'T ❗

The following is a strict copy of the previous (upstream) project ReadMe. This means that 'I' in the text does not refer to me but to VincentBlondeau.


This binding is done through UFFI primitive calls (a NativeBoost binding version can be found in the history of the project).

Installation

In order to get it work, you should get the R libs.

Under ubuntu

It is better to have a 32 bits version of Ubuntu to get the libraries. I tried with a 64 bits version but did not succeded to have it working. To get them:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install r-base-core:i386 https://github.com/VincentBlondeau

And copy the librairies ("libR.so") in the Pharo vm folder.

Under Windows 7

You should install R in 32bits (http://cran.r-project.org/bin/windows/base/) and copy the files R.dll, Rblas.dll, Rgraphapp.dll, Riconv.dll, Rlapack.dll and Rzlib.dll from R-3.1.1\bin\i386 to the pharo vm folder.

The libraries alone are not enough, you need to install R completly.

Under MacOs

Not tried

Package Loading

Once you have your libraries, you can launch a Pharo image with the RProjectConnector installed:

Gofer it 
    smalltalkhubUser: 'VincentBlondeau' project: 'RProjectConnector';
    configuration;
    loadStable

You have to restart Pharo to initialize the binding.

If you forgot to install the libraries or if they are not well installed, you should received a error startup but you are still able to launch your image.

Features and examples

If you want to execute a R function, you should (for now) know what is the name of the function and the parameters that it takes. If you misspeled the function name, the Pharo image will crash (that's a feature of R, that doesn't handle well the errors ;) ).

For example, if you want to evaluate the method 'acf' (Autocorrelation function) on a sample of data, you can do:

 data := (1 to: 1000) collect: #yourself.
 res := 'acf' asREval: {data}

You should get a representation of a list under R (a RList) and you can interract with it by accessing the items either by index or by key (the list are kind of dictionnary-arrays):

 res at: 'coef'
 res at: 1

Moreover, you have the visualisation of the acf opened in a other window.

Like that, you can evaluate any method with ordered parameters.

Some other examples with named and not named parameters:

 'plot'
      asREval:
           {(Object allSubclasses collect: #numberOfMethods).
           (Object allSubclasses collect: [ :e | e name size ]).
           ('xlim' -> #(0 700)).
           ('ylim' -> #(0 700)).
           ('xlab' -> 'Nb of Methods').
           ('ylab' -> 'Name lengthf').
           ('pch' -> 21).
           ('las' -> 1).
           ('bg' -> 'gold').
           ('cex' -> 1.6).
           ('cex.lab' -> 1.4).
           ('cex.axis' -> 1.4)}

For now there is no control of session in the image, try to not use R objects from previous sessions...

To do

Links

About

RProjectConnector is a library providing a binding between Pharo and R

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published