Proxy interface {RPgSQL}R Documentation

Bind a proxy object to a PostgreSQL table

Description

bind.db.proxy returns a proxy object bound to a database table.
row.names returns a name for each row in the proxy frame.
dimnames returns the dimension names.
as.list converts a proxy frame to a list.
as.matrix converts a proxy frame to a matrix.
[[.db.proxy extracts columns, rows and subsets of the proxy frame.
[.db.proxy extracts columns, rows and subsets of the proxy frame.
as.data.frame convert proxy to data frame.
db.has.row.names were row names stored in the database table?
names get column names.
dim get frame dimensions.
summary summarize proxy frame.
print print some of the proxy frame.
db.table.name get the database table name from the proxy frame.

Usage

bind.db.proxy(table.name, vacuum=F)
row.names(proxy)
dimnames(proxy)
as.list(proxy)
as.matrix(proxy)
proxy[[row, col]]
proxy[row, col]
as.data.frame(proxy)
db.has.row.names(proxy)
names(proxy)
dim(proxy)
summary(proxy)
print(proxy)
db.table.name(proxy)

Arguments

table.name A character string with the name of a table
vacuum If true, update table statistics
row A row index
col A column index
proxy A db.proxy object

Details

Proxy object inherit from class "data.frame". In theory, a proxy object should behave in every way like a data frame. Unfortunately, this is difficult the way objects are handled internally by R.

Value

bind.db.proxy returns a proxy object. No data, other than the table name, host and database name, are stored in the proxy object.

Note

In order to make proxy objects work, I had to make row.names a generic object method. This may break other packages.

Author(s)

Timothy H. Keitt

Examples

if (db.connection.open()) {
  data(airquality)
  rpgsql.test.data <- airquality
  rm(airquality)
  db.write.table(rpgsql.test.data, no.clobber=F)
  bind.db.proxy("rpgsql.test.data")
  summary(rpgsql.test.data)
  rpgsql.test.data
  rpgsql.test.data[50:55,]
  rpgsql.test.data[["Ozone"]]
  #This doesn't work
  rpgsql.test.data$Ozone
  #Clean up
  db.rm("rpgsql.test.data", ask=F)
}