From 33505b579dc2c83914523830c063ce844a4fe447 Mon Sep 17 00:00:00 2001 From: hadley Date: Thu, 10 Mar 2016 09:37:19 -0600 Subject: [PATCH] Better language --- functions.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions.Rmd b/functions.Rmd index b95d0d0..fa4084b 100644 --- a/functions.Rmd +++ b/functions.Rmd @@ -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: