Learn R Programming

vetr (version 0.2.18)

abstract: Turn S3 Objects Into Templates

Description

Create templates for use by alike. Currently somewhat experimental; behavior may change in future.

Usage

abstract(x, ...)

# S3 method for data.frame abstract(x, ...)

# S3 method for default abstract(x, ...)

# S3 method for array abstract(x, ...)

# S3 method for matrix abstract(x, ...)

# S3 method for list abstract(x, ...)

# S3 method for lm abstract(x, ...)

# S3 method for environment abstract(x, ...)

# S3 method for ts abstract(x, what = c("start", "end", "frequency"), ...)

Value

abstracted object

Arguments

x

the object to abstract

...

arguments for methods that require further arguments

what,

for time series which portion of the ts attribute to abstract, by default all three are abstracted, but you can select, any one, two, or all

Time Series

alike will treat time series parameter components with zero in them as wildcards. This function allows you to create these wild card time series attributes since R does not allow direct creation/modification of ts attributes with zero values.

Make sure you do not try to use the templates you create with this for anything other than as alike templates since the result is likely undefined given R expects non zero values for the ts attribute and attempts to prevent such attributes.

Details

abstract is intended to create templates for use by alike. The result of abstraction is often a partially specified object. This type of object may not be suited for use in typical R computations and may cause errors (or worse) if you try to use them as normal R objects.

There is no guarantee that the abstracted object is suitable for use as a template to alike as is. You may need to modify it further so that it suits your purposes.

abstract is an S3 generic. The default method will dispatch on implicit classes, so if you attempt to abstract an object without an explicit abstract method, it will get abstracted based on its implicit class. If you define your own abstract method and do not wish further abstraction based on implicit classes do not use NextMethod.

S4 and RC objects are returned unchanged.

Examples

Run this code
iris.tpl <- abstract(iris)
alike(iris.tpl, iris[1:10, ])
alike(iris.tpl, transform(iris, Species=as.character(Species)))

abstract(1:10)
abstract(matrix(1:9, nrow=3))
abstract(list(1:9, runif(10)))

Run the code above in your browser using DataLab