flights <- flights %>%
mutate(gain = dep_delay - arr_delay)
// mutate is use to save the result of some variable in new variable
mutate(.data, ...)
# S3 method for data.frame
mutate(
.data,
...,
.keep = c("all", "used", "unused", "none"),
.before = NULL,
.after = NULL
)
transmute(.data, ...)
starwars %>%
select(name, mass, species) %>%
mutate(mass_norm = mass / mean(mass, na.rm = TRUE))