On 6/4/05, Rajarshi Guha <[EMAIL PROTECTED]> wrote:
> On Sat, 2005-06-04 at 13:18 -0700, Joe Conway wrote:
> > Gabor Grothendieck wrote:
> > > On 6/4/05, Adam Witney <[EMAIL PROTECTED]> wrote:
> > >>I am using PL/R in PostgreSQL amd have written some functions to
> > build my
> > >>data frame. However this can take some time with some large datasets
> > and I
> > >>would like to not have to repeat the process and so I would like to
> > save the
> > >>data frame. Rather than save/load into the file system I would like
> > to be
> > >>able to save the entire data frame as a single object in the
> > database
> > >>
> > >>Is this possible?
> > >
> > > Check out ?serialize
> >
> > Looks like serialize should work nicely:
> >
> > create or replace function test_serialize(text)
> >   returns text as '
> >    mydf <- pg.spi.exec(arg1)
> >    return (serialize(mydf, NULL, ascii = TRUE))
> > ' language 'plr';
> 
> I was trying to do something similar but I needed to this from R itself.
> That is, I'd like to save a data.frame or a lm object to a DB.
> 
> I looked at serialize but as it just takes a connection object I'm not
> sure as to how I would specify say a table in a given DB.
> 
> I'm using R 2.0.1, PostgreSQL and Rdbi and Rdbi.PostgreSQL.
> 
> I've looked at the docs and I see that there are helper functions to
> write a table containing text, numeric or boolean. But its not clear to
> me how I would write an arbitrary object to a DB.

Look at 

R> example(serialize)

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to