R PostgreSQL Package

What is it?

The RPgSQL package for R allows users to read and write data frames to and from a postgresql database.  No knowledge of SQL is necessary to use the postgres package.  However, a low-level interface is also provided for sending SQL queries to the postgresql backend, and retrieving results.  The package also has support for "proxy" data frames.  A data frame proxy is an R object that inherits from the data.frame class, but contains no data.  All accesses to the proxy data frame generate the appropriate SQL query and retrieve the resulting data from the postgresql backend.  When this interface is complete, you will be able to process arbitrarily large data frames without loading everything into memory.

More information

"R" is an implementation of the "S" statistical computing language.  You can find information about R here.
PostgreSQL is a relational database system.  You can find information about postgresql here.

If you are interested in contributing, visit the source forge project page here.  I have also written a short contributing HOWTO.

Download

Download the package here.   See the R FAQ for instructions on installing packages.

Proxy example

bnd.pr> data(airquality)

bnd.pr> db.write.table(airquality, no.clobber = F)

bnd.pr> bind.proxy("airquality")

bnd.pr> summary(airquality)
Table name: airquality 
Database: test 
Host: localhost
Dimensions: 6 (columns) 153 (rows)


bnd.pr> print(airquality)
   Day Month Ozone Solar.R Temp
1    1     5    41     190   67
2    2     5    36     118   72
3    3     5    12     149   74
4    4     5    18     313   62
5    5     5    NA      NA   56
6    6     5    28      NA   66
7    7     5    23     299   65
8    8     5    19      99   59
9    9     5     8      19   61
10  10     5    NA     194   69
Continues for 143 more rows and 1 more cols...

bnd.pr> airquality[50:55, ]
   Ozone Solar.R Wind Temp Month Day
50    12     120 11.5   73     6  19
51    13     137 10.3   76     6  20
52    NA     150  6.3   77     6  21
53    NA      59  1.7   76     6  22
54    NA      91  4.6   76     6  23
55    NA     250  6.3   76     6  24

bnd.pr> airquality[["Ozone"]]
  [1]  41  36  12  18  NA  28  23  19   8  NA   7  16  11  14  18  14  34   6
 [19]  30  11   1  11   4  32  NA  NA  NA  23  45 115  37  NA  NA  NA  NA  NA
 [37]  NA  29  NA  71  39  NA  NA  23  NA  NA  21  37  20  12  13  NA  NA  NA
 [55]  NA  NA  NA  NA  NA  NA  NA 135  49  32  NA  64  40  77  97  97  85  NA
 [73]  10  27  NA   7  48  35  61  79  63  16  NA  NA  80 108  20  52  82  50
 [91]  64  59  39   9  16  78  35  66 122  89 110  NA  NA  44  28  65  NA  22
[109]  59  23  31  44  21   9  NA  45 168  73  NA  76 118  84  85  96  78  73
[127]  91  47  32  20  23  21  24  44  21  28   9  13  46  18  13  24  16  13
[145]  23  36   7  14  30  NA  14  18  20