Data Science Desktop Survival Guide
by Graham Williams |
|||||
Pipe Operator |
%>%
)
and became part of base R in 2021 (|>
).
To illustrate the concept of pipes recall the contents of the dataset
(rattle::weatherAUS):
# Review the dataset of weather observations.
ds
We might be interested in the distribution of specific numeric variables. For that we will dplyr::select() a few numeric variables using a pipe. |
# Select variables from the dataset.
ds %>% select(min_temp, max_temp, rainfall, sunshine)
Typing ds by itself lists the whole dataset. Piping the whole dataset to dplyr::select() using the pipe tidyr::https://www.rdocumentation.org/packages/tidyr/topics/end result returned as the output of the pipeline is a subset of the original dataset containing just the named columns. |