Skip to Content

monet.frame {MonetDB.R}

Virtual R data object for MonetDB tables and query results
Package: 
MonetDB.R
Version: 
0.8.0

Description

monet.frame wraps a MonetDB table or query result and behaves like a R data.frame.

Usage

monet.frame( conn, tableOrQuery, debug=FALSE )

Arguments

conn
A MonetDB.R database connection. Created using dbConnect with the MonetDB.R database driver.
tableOrQuery
A string either naming a database table or a SQL query as a basis for the new object.
debug
Logical value indicating whether the SQL queries being rewritten in the background are printed or not.

Details

monet.frame wraps a MonetDB table or query result and behaves like a R data.frame. Many operations typical for data.frame are supported, e.g. $, [, basic math and comparisons. Data is only loaded when as.data.frame or as.vector are called, and most basic operations and calculations are mapped to SQL statements. This greatly reduces the amount of data that has to be transferred between MonetDB and R and thereby also increases speed, allowing you to analyse even more data with R. So far, the following user-facing R functions are implemented by monet.frame objects. The signatures and semantics of these methods closely follow those implemented for data.frame objects.

  • mf -- Shorthand constructor, also creates a DB connection
  • as.data.frame -- DB table or query result to R data.frame object
  • as.vector -- Single DB column to R vector
  • str -- Display object structure (SQL query, columns, data types, ..)
  • print -- Prints database content wrapped in object to screen)
  • summary -- Calculates summaries on wrapped database content)
  • names -- Gets the column names of the wrapped query result or table as vector
  • dim -- Gets the dimension (#rows/#cols) of the wrapped query result or table
  • length -- Gets the number of columns of the wrapped query result or table
  • na.fail -- Raise an error if any value is NA/NULL (only for single columns)
  • head -- Gets the first n rows from the wrapped query result or table as data.frame
  • tail -- Gets the last n rows from the wrapped query result or table as data.frame
  • [ -- Extracts specific rows and columns from the wrapped object, behaves like [ on data.frame
  • $ -- Extracts a single column from the wrapped object, behaves like $ on data.frame
  • subset -- Returns a subset of the wrapped table that meets filter conditions
  • na.omit -- Filters out NA/NULL values (only for single columns)
  • sample -- Gets n randomly selected rows of the wrapped query result or table as data.frame
  • S3 Group Generic Functions
  • sd -- Calculates the standard deviation (only for single columns)
  • var -- Calculates the variance (only for single columns)
  • quantile -- Provides quantile values (only for single numeric columns)
  • median -- Retrieves the Median value (only for single numeric columns)
  • aggregate -- Computes summary statistics by groups
  • aggregatef -- Computes summary statistics by groups using formula
  • rbind -- Combines monet.frame objects of compatible structure through concatenation
  • merge -- Merge two monet.frame objects together using a DB JOIN operation
  • sort -- Sort a database column ascending or descending (only for single columns)
  • tabulate -- Counts the number of value occurences (only for single numerical columns)
  • range -- Gives range of values (only for single numerical columns)

Values

Returns a monet.frame virtual data object that behaves similar to a data.frame.

See Also

data.frame

Examples

## Not run:
# connect to MonetDB
conn <- dbConnect(MonetDB.R(), "monetdb://localhost/demo")
# write some test data
data(iris)
dbWriteTable(conn, "iris", iris)
# construct monet.frame
frame <- monet.frame(conn,"iris")
# show description
str(frame)
# select one of the colums
frame$sepal_width
# select ten rows and the first two columns
frame[1:10,1:2]
# calculate aggregation
mean(frame$sepal_width)
## End(Not run)

Documentation reproduced from package MonetDB.R, version 0.8.0. License: MPL (== 1.1)