Writing functions for use in dplyr::mutate()

The mutate() function from dplyr is extremely useful one for adding new columns to a dataframe based on computations from existing columns. It is a vectorized function, though, and is often misunderstood as working row-wise when it actually works column-wise, that is, on whole vectors with R's built-in recycling. This behavior can often be confusing for those looking to use mutate() on non-trivial examples or with custom functions, so, in this recipe, we're going to examine how mutate() actually behaves in certain situations, with the hope that this will be enlightening.

..................Content has been hidden....................

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