Learn R Programming

commandr (version 1.0.1)

Protocol-class: Protocol: Concrete Step in a Pipeline

Description

A Protocol object performs a Stage in a particular way, as part of a Pipeline. Most users will simply construct a Protocol and add it to a pipeline. To define a new type of Protocol, see setProtocol.

Arguments

Constructors

Protocol(role, method = defaultMethod(role), ...): Creates a protocol of the stage identified by role and method given by method. The role argument may be either a Stage object or a string naming the role. Parameters in ... are passed to the initializer, i.e., they specify parameters of the protocol by name.

Accessors

stage(object, where = topenv(parent.frame())): Return a Stage object that represents the role this protocol plays in a pipeline. Searches for the class definition of the stage in where.
method(object, where = topenv(parent.frame())): Returns the method name of this protocol. This is derived from the class name of the protocol by removing the stage name. The environment where should contain the definition of the stage class.
displayName(object): Gets the name for displaying this protocol in a user interface.
inType(object): Gets the class of data that this protocol accepts as input.
outType(object): Gets the class of data that this protocol yields as output.
parameters(object): Gets the list of parameters, i.e., the slots of the object, that control the execution of the protocol.
pipeline(object): Some protocols delegate to a secondary pipeline, i.e., they have a slot named "pipeline". This function retrieves that, or returns NULL if the protocol does not delegate to a pipeline.

See Also

setProtocol for defining new types of protocols

Examples

Run this code
setStage("average", intype = "numeric")
setProtocol("mean", fun = mean, parent = "average")
setProtocol("quantile", representation = list(probs = "numeric"),
            fun = quantile, parent = "average")

proto_avg_mean <- Protocol("average")
proto_avg_mean <- Protocol("average", "mean")
proto_avg_quantile <- Protocol("average", "quantile")
proto_avg_quantile_075 <- Protocol("average", "quantile", probs = 0.75)

proto <- proto_avg_quantile_075
proto
stage(proto)
inType(proto)
parameters(proto)

Run the code above in your browser using DataLab