Learn R Programming

MonetDBLite (version 0.6.0)

mdbapply: Apply a R function to an external MonetDB table.

Description

dbApply uses the R UDF facilities in standalone MonetDB to apply the passed function to a table.

Usage

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

Arguments

conn

An external MonetDB.R database connection. Created using dbConnect with the MonetDB.R external database driver.

table

An external MonetDB database table. Can also be a view or temporary table.

fun

A R function to be run on the external 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 {
library(DBI)
con <- dbConnect(MonetDB.R(), "demo")
data(mtcars)
dbWriteTable(con, "mtcars", mtcars)

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

Run the code above in your browser using DataLab