MonetDB.R (version 1.0.1)

mdbapply: Apply a R function to a MonetDB table.

Description

dbApply is used to switch the data from the normal auto-commiting mode into transactional mode. Here, changes to the database will not be permanent until dbCommit is called. If the changes are not to be kept around, you can use dbRollback to undo all the changes since dbTransaction was called.

Usage

mdbapply(conn, table, fun, ...)

Arguments

conn

A MonetDB.R database connection. Created using dbConnect with the MonetDB.R database driver.

table

A MonetDB database table. Can also be a view or temporary table.

fun

A R function to be run on the database table. The function gets passed a single data.frame argument which represents the database table. The function needs to return a single vector (for now).

...

Other parameters to be passed to the function

Value

Returns the result of the function applied to the database table.

Examples

Run this code
# NOT RUN {
conn <- dbConnect(MonetDB.R(), "demo")
data(mtcars)
dbWriteTable(conn, "mtcars", mtcars)

mpgplus42 <- mdbapply(conn, "mtcars", "double", function(d) {
	d$mpg + 42
})
# }

Run the code above in your browser using DataCamp Workspace