dbApply {RMySQL} | R Documentation

## Apply R functions to remote groups of DBMS rows (experimental)

### Description

Applies R 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.

### Usage

    dbApply(res, ...)

### Arguments

`res` | a result set (see `dbSendQuery`).
`...` | any additional arguments to be passed to `FUN`.

### 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 `MySQL` driver implements a method (see the helper function `mysqlDBApply`) for this generic function.

### Value

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

### See Also

`MySQL` `mysqlDBApply` `dbSendQuery` `fetch`

### Examples

    ## Not run:
    ## compute quanitiles for each network agent
    con <- dbConnect(MySQL(), group="vitalAnalysis")
    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))
    ## End(Not run)

[Package RMySQL version 0.6-0 Index]