Learn R Programming

tidytable (version 0.5.1)

mutate.: Mutate

Description

Add new columns or modify existing ones

Usage

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

dt_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