[R] Issues with RPostgres

Hadley Wickham h.wickham at gmail.com
Thu Aug 27 23:42:08 CEST 2015


On Thu, Aug 27, 2015 at 3:46 PM, John McKown
<john.archie.mckown at gmail.com> wrote:
> On Thu, Aug 27, 2015 at 2:29 PM, Abraham Mathew <mathewanalytics at gmail.com>
> wrote:
>
>> I have a user-defined function that I'm using alongside a postgresql
>> connection to
>> summarize some data. I've connected to the local machine with no problem.
>> However,
>> the connection keeps throwing the following error when I attempt to use it.
>> Can anyone point
>> to what I could be doing wrong.
>>
>> > ds_summary(con, "test", vars=c("Age"), y=c("Class"))
>> Error in postgresqlNewConnection(drv, ...) :
>>   RS-DBI driver: (could not connect postgres at localhost on dbname "test"
>> )
>>
>>
>> con is the connection
>>
>
> It would be helpful to see the assignment to "con" as well as any other
> assignments related to this. If you are using the DBI package, then what I
> am talking about would be something like:
>
> drv<-dbDriver("PgSQL")
> con<-dbConnect(drb,user=...,password=...,dbname="test');

FWIW the best way to create a connection is:

library(DBI)
con <- dbConnect(RPostgreSQL::PostgreSQL(), ...)

The older string based approach is not advised.

Hadley
-- 
http://had.co.nz/



More information about the R-help mailing list