This operator “pipes” data from the source into the sink object.

If both objects are a CPO object, or both are a CPOTrained object, they will be composed. A new object, representing the operation of performing both object's operations in succession, will be created, which can be handled like a new CPO or CPOTrained object. See composeCPO.

If the source object is a data.frame or a link[mlr]{Task}, the transformation operation will be applied to this data, and the same resulting data will be returned. See applyCPO.

If the sink object is a Learner, the CPO will be attached to this learner. The same operation will be performed during the train and predict phase; the behaviour during the predict phase may furthermore be depend on the training data. See attachCPO.

Note that you can not link a data.frame or Task directly to a Learner, since this operation is not algebraically associative with the composition of CPOs. Use train for this.

The %<<% operator is synonymous with %>>% with source and sink argument swapped.

The %>|% and %|<% operators perform piping followed by application of retrafo. The %>|% evaluates the expression to its right before the expression to its left, so it may be used in the most natural way without parentheses:

data %>|% cpo1 %>>% cpo2

is the same as

retrafo(data %>>% cpo1 %>>% cpo2).

The %<>>% and %<<<% operators perform the piping operation and assign the result to the left hand variable. This way it is possible to apply a CPO, or to attach a CPO to a Learner, and just keep the resulting object. The assignment operators evaluate their right hand side before their left hand side, so it is possible to build long chains that end up writing to the leftmost variable. Therefore the expression

data %<>>% cpo1 %<>>% cpo2 %>>% cpo3

is the same as

cpo1 = cpo1 %>>% cpo2 %>>% cpo3
data = data %>>% cpo1
cpo1 %>>% cpo2

cpo2 %<<% cpo1

cpo1 %<>>% cpo2

cpo2 %<<<% cpo1

cpo1 %>|% cpo2

cpo2 %|<% cpo1



[data.frame | Task | CPO | CPOTrained]
The source object.


[CPO | CPOTrained | Learner]
The sink object.


[data.frame | Task | CPO | CPOTrained].

See also


# PCA-rotate pid.task = pid.task %>>% cpoScale() %>>% cpoPca() # Centering / Scaling *after* PCA newPCA = cpoPca() %>>% cpoScale() # Attach the above to learner pcaLogreg = newPCA %>>% makeLearner("classif.logreg") # append cpoAsNumeric to newPCA newPCA %<>>% cpoAsNumeric() print(newPCA)
#> (pca >> scale >> as.numeric)( = TRUE, pca.scale = FALSE, = TRUE, scale.scale = TRUE)
# prepend cpoAsNumeric to pcaLogreg pcaLogreg %<<<% cpoAsNumeric()