Compiling PL/R (R language module for PostgreSQL database)

Joe Conway mail at
Mon Feb 14 16:30:29 PST 2011

On 02/14/2011 01:32 PM, JP Glutting wrote:
> In case anyone is wondering what it does, my understanding is that it
> allows you to use R within a Postgres database, allowing you to build
> complex analytical functions within Postgres itself, instead of having
> to export the data, process it, and write back the results. (I am sure
> Joe will correct me if I am not quite correct).

That pretty much describes it.

Literally PL/R allows the R interpreter to run inside a Postgres backend
process as an extension, and execute R code through standard SQL
statements. You can pass SQL data in to an R function as arguments, and
return the results of the R function to the SQL side as the function
return value. There are also extensions installed into the R interpreter
that allow direct SQL execution from within the R function.

> I am planning to use it with a Postgis database to do some spatial
> interpolation on a dataset that spans 10 years, one day at a time. I am
> hoping it will allow me to process the data directly to results in the
> database  instead of having to export the data to R and then extract the
> interpolated values and pass them back to Postgres. 
> I am not entirely sure how I am going to do it (I just installed PL/R a
> few hours ago), but I am fairly sure it can be done. 

Pretty cool stuff. I did a 3 hour tutorial with a co-presenter at PgWest
a few months ago on a similar topic. In case you are interested, You can
grab the slides here:

Also, FWIW, I am giving a 90 minute mini-tutorial on PL/R at PgEast in
NYC in March. The agenda is not up yet, but see the following for dates,
venue, and eventually the schedule:

> So, if that sounds like the kind of thing you would like to do with
> Postgres, and you know how to package a port, this could be a good project.

Absolutely -- I would welcome any help :-)


Joe Conway
credativ LLC:
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the macports-users mailing list