mutate | R Documentation |
This function is very similar to transform
but it executes
the transformations iteratively so that later transformations can use the
columns created by earlier transformations. Like transform, unnamed
components are silently dropped.
mutate(.data, ...)
.data |
the data frame to transform |
... |
named parameters giving definitions of new columns. |
Mutate seems to be considerably faster than transform for large data frames.
subset
, summarise
,
arrange
. For another somewhat different approach to
solving the same problem, see within
.
# Examples from transform
mutate(airquality, Ozone = -Ozone)
mutate(airquality, new = -Ozone, Temp = (Temp - 32) / 1.8)
# Things transform can't do
mutate(airquality, Temp = (Temp - 32) / 1.8, OzT = Ozone / Temp)
# mutate is rather faster than transform
system.time(transform(baseball, avg_ab = ab / g))
system.time(mutate(baseball, avg_ab = ab / g))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.