R users who also use the dplyr package will be able to quickly understand the following code that adds an estimated area column to a data.frame.
1 | |
1 |
|
The notation we used above is the “explicit argument” variation we recommend for readability. What a lot of dplyr users do not seem to know is: base-R already has this functionality. The function is called transform().
To demonstrate this, let’s first detach dplyr to show that we are not using functions from dplyr.
1 | |
Now let’s write the equivalent pipeline using exclusively base-R.
1 | |
1 |
|
The “->.” notation is a the end-of-line variation of the Bizarro Pipe. The transform() function has been part of R since 1998. dplyr::mutate() was introduced in 2014.
1 | |
Like this:
Like Loading…
Related