DVK
DVK

Reputation: 129433

What is a recommended R interface for Perl integration?

I never dealt with R, so I was wondering if anyone can recommend (either from personal experience or some reviews/comparisons) which of the several Perl/R integration modules are considered "best practices"? Ideally something which could somehow qualify for production readiness.

Google shows several different modules but I am not quite sure how to evaluate the options, having zero previous R or statistics experience (the question came from a co-worker who was interested in using R)

Upvotes: 5

Views: 1867

Answers (6)

Zakariyya Mughal
Zakariyya Mughal

Reputation: 88

I've just released Statistics::NiceR. It has support for pretty much all R data types including data.frames.

It's an early release, so I'd like feedback. This is what it looks like:

#!/usr/bin/env perl
use v5.16;
use Statistics::NiceR;
use Data::Frame::Rlike;

my $r = Statistics::NiceR->new;
my $iris = $r->get('iris');

say "Subset of Iris data set";
say $iris->subset( sub { # like a SQL WHERE clause
                  ( $_->('Sepal.Length') > 6.0 )
                & ( $_->('Petal.Width')  < 2   )
        })->select_rows(0, 34); # grab the first and last rows

which outputs

Subset of Iris data set
-----------------------------------------------------------------------
      Sepal.Length  Sepal.Width  Petal.Length  Petal.Width  Species
-----------------------------------------------------------------------
 51   7             3.2          4.7           1.4          versicolor
 147  6.3           2.5          5             1.9          virginica
-----------------------------------------------------------------------

Upvotes: 1

Davor Cubranic
Davor Cubranic

Reputation: 1120

If you want to just read R data files, my module Statistics::R::IO would fit the bill. It's a pure Perl implementation that reads both RDS and RData files.

Starting with version 0.4, released last week, you can also use it as an Rserve client.

Upvotes: 1

Djun Kim
Djun Kim

Reputation: 1

I have recently added Statistics::RserveClient to CPAN. This allows perl applications to interact with a (possibly remote) Rserve server via a connection-oriented binary protocol. You send R code to the server as strings, and the results are returned as perl data structures.

There are a number of shortcomings - we don't support long packets yet, or deal properly with certain heterogeneous structures, but the code is under active development, and it works quite nicely for our basic applications.

The code is GPL, hosted at https://github.com/djun-kim/Statistics--RserveClient

Upvotes: -1

draegtun
draegtun

Reputation: 22560

I've personally not used it but Statistics::R looks interesting. Its got a 3 star review on CPAN ratings and is currently going through a face lift with a new maintainer.

/I3az/

Upvotes: 3

Robert Buels
Robert Buels

Reputation: 184

Yes, looks like Statistics::R is probably your best bet. It's been updated recently, Brian Cassidy is a competent developer, and it's passing its CPAN smoke tests.

There is also Statistics::useR, it has been touched relatively recently, but that one doesn't seem to be compliant with CPAN's smoke testing system, which makes me a bit nervous.

That said, I haven't used either of these.

Upvotes: 7

Dirk is no longer here
Dirk is no longer here

Reputation: 368271

What are your actual requirements in terms of

  • OS that R is running on
  • OS that Perl clients are running on
  • type of query you plan: 'canned' or interactive

etc pp.

I have long been a fan of Rserve as a headless R backend but I can't recall if there was a Perl client.

Upvotes: 2

Related Questions