db.lapply | R Documentation |
Apply a function to rows in a result set
db.lapply(db, stmt, params, FUN, ...)
db |
The database connection. An S4 object of class "database". |
stmt |
The SQL statement to evaluate. |
params |
A matrix, data.frame, or list of lists with parameters. |
FUN |
The function to apply. |
... |
Additional arguments to FUN. |
Function FUN is called on each row returned by the query stmt. The first argument to FUN will be a named list containing the fields for a row returned by the stmt. Subsequent arguments to FUN are passed via ...
A list, each element of which is the result of applying FUN to a row in the result set.
db.eval
db = db.open()
db.eval(db, "CREATE TABLE t(a REAL, b REAL)")
db.eval(db, "INSERT INTO t VALUES(?,?)", matrix(runif(200), 100, 2))
db.lapply(db, "SELECT * FROM t", FUN=function(r) sum(unlist(r)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.