Learn R Programming

MonetDB.R (version 0.8.0)

monet.frame: Virtual R data object for MonetDB tables and query results

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.

Value

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

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 Rdata.frameobject
  • as.vector-- Single DB column to Rvector
  • 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 asdata.frame
  • tail-- Gets the last n rows from the wrapped query result or table asdata.frame
  • [-- Extracts specific rows and columns from the wrapped object, behaves like[ondata.frame
  • $-- Extracts a single column from the wrapped object, behaves like$ondata.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 asdata.frame
  • S3 Group Generic Functions
  • abs,sign,sqrt,floor,ceiling,trunc,round,signif
  • exp,log,expm1,log1p,cos,sin,tan,acos,asin,atan,cosh,sinh,tanh,acosh,asinh,atanh
  • "+","-","*","/","^","%%","%/%"
  • "&","|","!"
  • "==","!=","<"< code="">,"<="< code="">,">=",">"
  • min,max,sum,range,prod
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) data.frame # 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) interface