Description Usage Arguments Details Value See Also Examples
monet.frame
wraps a MonetDB table or query result and behaves like a R data.frame
.
1 | monet.frame( conn, tableOrQuery, debug=FALSE )
|
conn |
A MonetDB.R database connection. Created using |
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. |
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
abs
, sign
, sqrt
, floor
, ceiling
, trunc
, round
, signif
exp
, log
, expm1
, log1p
, cos
, sin
, tan
, acos
, asin
, atan
, cosh
, sinh
, tanh
, acosh
, asinh
, atanh
"+"
, "-"
, "*"
, "/"
, "^"
, "%%"
, "%/%"
"&"
, "|"
, "!"
"=="
, "!="
, "<"
, "<="
, ">="
, ">"
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)
Returns a monet.frame
virtual data object that behaves similar to a data.frame
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.