Learn R Programming

RPostgreSQL (version 0.7-5)

dbApply: Apply R/S-Plus functions to remote groups of DBMS rows (experimental)

Description

Applies R/S-Plus functions to groups of remote DBMS rows without bringing an entire result set all at once. The result set is expected to be sorted by the grouping field.

Arguments

Value

A list with as many elements as there were groups in the result set.

Details

dbApply This generic is meant to handle somewhat gracefully(?) large amounts of data from the DBMS by bringing into R manageable chunks; the idea is that the data from individual groups can be handled by R, but not all the groups at the same time.

Currently, only the PostgreSQL driver implements a method (see the helper function postgresqlDBApply) for this generic function.

See Also

PostgreSQL postgresqlDBApply dbSendQuery fetch

Examples

Run this code
if (FALSE) {
## compute quantiles for each network agent
con <- dbConnect(PostgreSQL(), user= "user", password="passwd", dbname="sample")
rs <- dbSendQuery(con, 
             "select Agent, ip_addr, DATA from pseudo_data order by Agent")
out <- dbApply(rs, INDEX = "Agent", 
        FUN = function(x, grp) quantile(x$DATA, names=FALSE))
}

Run the code above in your browser using DataLab