John Mount points out that there is a built-in function to mutate data frames in R:
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 calledtransform()
.To demonstrate this, let’s first detach
dplyr
to show that we are not using functions fromdplyr
.detach("package:dplyr", unload = TRUE)
Now let’s write the equivalent pipeline using exclusively base-
R
.
Click through for the way to do this as a pipeline operation.