Thx for you help Laurent, I'm change my code for this :
rconn = r.dbConnect
bdobj = r.PgSQL
print "--\n"
print bdobj
conn = rconn( bdobj(), host="localhost", dbname="simpop", user="postgres",
pass\
word="postgres")
*with a different execution error : *
Error in dbConnectionInfo.PgSQL.conn(conn) :
SET_VECTOR_ELT() can only be applied to a 'list', not a 'character'
Traceback (most recent call last):
File "s_ranktail_resume_rpy2.py", line 19, in <module>
rconn( bdobj(), host="localhost", dbname="simpop", user="postgres",
password="postgres")
File "/usr/lib/python2.5/site-packages/rpy2/robjects/__init__.py", line
422, in __call__
res = super(RFunction, self).__call__(*new_args, **new_kwargs)
rinterface.RRuntimeError: Error in dbConnectionInfo.PgSQL.conn(conn) :
SET_VECTOR_ELT() can only be applied to a 'list', not a 'character'
An idea of problem ? perhaps i need to utilize sexp** ??
Thx for you help !
On Tue, Jul 7, 2009 at 6:48 PM, Laurent Gautier <lgaut...@gmail.com> wrote:
> reyman wrote:
>
>> Hello,
>> I have problem with last version of R and rpy classic, so i try to convert
>> my source code into rpy2, but i have problem to understand with calling
>> function into a function
>>
>> Exemple with my db connection :
>> *
>> /With rpy classic, it's ok : /*
>>
>> rpy.set_default_mode(rpy.NO_CONVERSION)
>> r('conn <- dbConnect(PgSQL(), host="localhost", dbname="simpop",
>> user="postgres", password="postgres")')
>> *
>> /With rpy2, error :/*
>>
>>
> The *same* with rpy2 would then be:
>
> import rpy2.robjects as robjects
>
> robjects.r('conn <- dbConnect(PgSQL(), host="localhost", dbname="simpop",
> user="postgres", password="postgres")')
>
>
>
> import rpy2.robjects as robjects
>> import sys
>> import math
>>
>> r = robjects.r
>>
>> r.library("Rdbi")
>> r.library("RdbiPgSQL")
>> r.library("ggplot2")
>>
>
> (note: You may want to already check the graphics (and ggplot2) niceties in
> rpy2-2.1-dev (a snapshot of the doc in online).)
>
> #Connect to DB with RPY2
>> rconn = r.dbConnect
>> bdobj = r.PgSQL
>>
>> print bdobj
>>
>> conn = rconn( bdobj, host="localhost", dbname="simpop", user="postgres",
>> password="postgres")
>> *
>> /At execution : /*
>>
>> function ()
>> {
>> out <- list(description = "PostgreSQL object")
>> class(out) <- c("PgSQL", "Rdbi")
>> return(out)
>> }
>> <environment: namespace:RdbiPgSQL>
>> Error in dbConnect.default(function () : Invalid database class
>> Traceback (most recent call last):
>> File "s_ranktail_resume_rpy2.py", line 19, in <module>
>> conn = rconn( bdobj, host="localhost", dbname="simpop",
>> user="postgres", password="postgres")
>> File "/usr/lib/python2.5/site-packages/rpy2/robjects/__init__.py", line
>> 422, in __call__
>> res = super(RFunction, self).__call__(*new_args, **new_kwargs)
>> rinterface.RRuntimeError: Error in dbConnect.default(function () :
>> Invalid database class
>>
>> I don't understand where is the problem ?
>>
>
> I think that the problem is what the error message tells: you are feeding
> rconn() with an invalid database class, and that invalid class happen to be
> a function. You are most certainly passing dbobj while you should be passing
> dbobj().
>
>
> L.
>
> >
>
>> Thx a lot with a newbie on python/R/Rpy2
>> Seb
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> Enter the BlackBerry Developer Challenge This is your chance to win up to
>> $100,000 in prizes! For a limited time, vendors submitting new applications
>> to BlackBerry App World(TM) will have the opportunity to enter the
>> BlackBerry Developer Challenge. See full prize details at:
>> http://p.sf.net/sfu/blackberry
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> rpy-list mailing list
>> rpy-list@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rpy-list
>>
>
>
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list