[R] R, postgresql, windows & bsd

Jim McLoughlin jimmcloughlin at earthlink.net
Thu Jan 13 18:48:02 CET 2005


On Jan 13, 2005, at 6:07 AM, v.demartino2 at virgilio.it wrote:

> I usually work with R on a windows querying data through RODBC from a 
> postgresql
> db on a freebsd machine on my offcie lan.
> Now I have the chance to use R also on a linux gentoo client box and to
> connect to the same db.
> I know that I can install   the unixodbc stuff and stick to RODBC, BUT 
> my
> question is:
>
> Is there any more 'linuxish' way of querying a postgresql server from a
> client?

Use the Rdbi and RdbiPgSQL packages from www.bioconductor.org.  You 
will need to have the postgresql client libraries installed beforehand 
- the installation of these packages will ask you for the Postgresql 
library and include paths.

Once installed, queries are easy.  For example:

         library(Rdbi)
         pcon <- dbConnect(PgSQL(),host="myIP", 
dbname="myDBName",user="me",password="mypasswd")
         myquery <- paste("select * from mytable")
         resultDataframe <- dbGetQuery(pcon,myquery)
         dbDisconnect(pcon)




More information about the R-help mailing list