Function Framework

Every data transformation function in dplyr accepts a data frame as its first input parameter and returns the transformed data frame back as an output. A blueprint for a typical dplyr function looks like this:

Input
transformed <- dplyr_function(my_data_frame, 
                              param_one, 
                              param_two, 
                              ...) 

The dplyr_function can be customized further through additional arguments (param_one, param_two) placed after the first data frame parameter (my_data_frame).

The real power of dplyr comes with the pipe operator %>% which allows users to concatenate dplyr functions to data pipelines. The pipe injects the resulting data frame from the previous calculation as the first argument of next one. A data transformation consisting of three functions looks like

Input
dplyr_function_three(
  dplyr_function_two(
    dplyr_function_one(my_data_frame)))

but can be written with the pipe as

Input
my_data_frame %>%
  dplyr_function_one() %>%
  dplyr_function_two() %>%
  dplyr_function_three()

The different reading order of data transformation functions in actual transformation order makes pipelines easier to read than nested function calls.

Introduction to dplyr