Re: Using PL/R for predictive analysis of data. - Mailing list pgsql-general

From Sam Mason
Subject Re: Using PL/R for predictive analysis of data.
Date
Msg-id 20080314181936.GZ1653@frubble.xen.chris-lamb.co.uk
Whole thread Raw
In response to Using PL/R for predictive analysis of data.  ("Mr.Frog.to.you@googlemail.com" <Mr.Frog.to.you@googlemail.com>)
Responses Loging of postgres requests
List pgsql-general
On Wed, Mar 12, 2008 at 09:35:24AM -0700, Mr.Frog.to.you@googlemail.com wrote:
> In short R appears to have more than enough capability to do the job
> (from a statistical perspective), however there doesnt seem to be that
> much discussion on using the PL/R implementation, or for that matter
> tutorials on using PL/R.

I've not used PL/R either, but I've used R on it's own a bit and I've
done a bit of PL/pgSQL programming as well.

> What I would like to know is:
> 1/ Is is possible to create a view that has its columns based on the
> output of a PL/R function?

You're after something called set returning functions, i.e. a function
that has "RETURNS SETOF" in it's definition.  There's an example in the
docs[1].  To create a view from this example, do

  CREATE VIEW emps AS
    SELECT * FROM get_emps();

The problem with this is that the optimiser can't "see inside" the
function and do much fancy optimisation any more.  I can't help with
your other questions.

> Any advice or counsel would be greatly appreciated.

I'd get everything working separately before trying to bring it all
together.  I.e. get the regressions working in plain R using data
extracted by hand before trying to do everything in PG.


  Sam

pgsql-general by date:

Previous
From: "Dean Gibson (DB Administrator)"
Date:
Subject: Re: Can't rename an existnig DB because it doesn't exist???
Next
From: "Scott Marlowe"
Date:
Subject: Re: postgre vs MySQL