Piping data between functions

We can obtain the same results by piping the data between functions. Piping is denoted using the symbols %>% in R programming. It is available from the magrittr package. The piping symbols are normally thought of as synonyms for then in English. For example, the R statement data %>% function() means take the data object and then pass it along to the function(), just as if we had entered the statement function(data).

To produce the same summary on a calculated field using piping, we would write the following (meaning take the pct dataset and then pipe it into the summarize function, and take the hitpct field and pipe it into the mean function):

library(magrittr) pct %>% summarize(hitpct %>% mean(na.rm = TRUE))
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.197.26