Learn R Programming

tidytable (version 0.5.8)

mutate.: Add/modify/delete columns

Description

With mutate.() you can do 3 things:

  • Add new columns

  • Modify existing columns

  • Delete columns

Usage

mutate.(.df, ..., .by = NULL)

Arguments

.df

A data.frame or data.table

...

Columns to add/modify

.by

Columns to group by

Examples

Run this code
# NOT RUN {
test_df <- data.table(
  a = c(1,2,3),
  b = c(4,5,6),
  c = c("a","a","b"))

test_df %>%
  mutate.(double_a = a * 2,
          a_plus_b = a + b)

test_df %>%
  mutate.(double_a = a * 2,
          avg_a = mean(a),
          .by = c)
# }

Run the code above in your browser using DataLab