Better language

This commit is contained in:
hadley 2016-03-10 09:37:19 -06:00
parent c6629dcd1c
commit 33505b579d
1 changed files with 2 additions and 2 deletions

View File

@ -649,9 +649,9 @@ This tends to make the code easier to understand, because you don't need quite s
### Writing pipeable functions
If you want to write your own pipeable functions, thinking the return value is key. There are two key pipes of pipeable functions.
If you want to write your own pipeable functions, thinking about the return value is important. There are two main types of pipeable functions.
In __transformation__ functions, there's a clear "key" object that is passed in as the first argument, and a modified version is returned by the function. For example, the key objects for dplyr and tidyr are data frames. If you can identify what the object type is for your domain, you'll find that your functions just work in a pipe.
In __transformation__ functions, there's a clear "primary" object that is passed in as the first argument, and a modified version is returned by the function. For example, the key objects for dplyr and tidyr are data frames. If you can identify what the object type is for your domain, you'll find that your functions just work in a pipe.
__Side-effect__ functions, however, are primarily called to perform an action, like drawing a plot or saving a file, not transforming an object. These functions should "invisibly" return the first argument, so they're not printed by default, but can still be used in a pipeline. For example, this simple function that prints out the number of missing values in a data frame: