Description Usage Arguments Details Value Slots The Container class Advantages of using Containers Using the class Extending the Container class See Also
A general, extensible and flexible container holding data and metadata.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Container(x, ...)
## S4 method for signature 'missing'
Container(x, schema = Schema(), ...)
## S4 method for signature 'character'
Container(x, schema = Schema(), ...)
## S4 method for signature 'data.frame'
Container(x, schema = Schema(), ...)
## S4 method for signature 'data.table'
Container(x, schema = Schema(), ...)
## S4 method for signature 'Schema'
Container(x, ...)
## S4 method for signature 'Container'
show(object)
|
x |
conceptually, any R object. Typically, a |
... |
further arguments passed to or from other methods:
|
schema |
a |
object |
a |
If a Schema
object is passed to Container()
, an empty
Container
is generated. It will have empty columns defined with names
and types matching the underlying Schema
. Argument schema
is ignored for that special case.
The constructor function Container()
returns an object of class Container
.
The show()
method returns NULL
invisibly. It is used for its-effect.
table
a data.table
. Its structure must
match what slot schema
prescribes.
schema
a Schema
holding metadata (column names,
types and prototypes) on the structure of table
.'
Class Container
is a general container designed to hold any kind of data
in an explicit, formal and rigorous way. It can be viewed as a compound
structure type which structure is declared through an instance of the
Schema
class.
There are four advantages to using the class.
Data manipulation is a seamless hybrid between
data.frame
and
data.table
classes.
Expression arguments
passed to operator [
are viewed as
data.table
statements.
Non-expression arguments are viewed as classical
data.frame
statements.
A minimal expected table
structure is always enforced for increased
reliability. This is fundamental in every automated applications expecting
specific information.
You don't have to define low-level details and checks. This reduces programming time while adding a negligible cost in compute time.
It is easier to share pre-defined Containers with structures
defined by Schema
objects.
Create objects of class Container
through the constructor function Container()
.
Validate instances of the class by using valid_container()
.
Test objects for class Container
with introspector function is_container()
.
Extract slots from instances of the class with functions table()
and schema()
.
Set new values to slots with functions table<-()
,
and schema<-()
.
Subset instances of the class by using the Container
methods implemented
for operators [
, [[
and
$
.
Methods for class Container
are implemented for generic functions
length()
, names()
, nrow()
, ncol()
, dim()
and show()
.
For most applications, the Container
class will not be specific enough.
Users should extend it to a super-class with additional slots by using
package methods. Class GeoContainer
is a
simple example; it adds a sptial component to class Container
.
Other Container:
Container-accessors
,
Container-extractors
,
Container-methods
,
Container-validators
,
is_container()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.