The dplyr::mutate function modifies, deletes or creates a new column for a data frame without altering the number of rows. The amplify function can create new columns which generally increase (or amplify) the size of the row dimension. The observations in other columns are duplicated.

amplify(.data, ...)

# S3 method for data.frame
amplify(
  .data,
  ...,
  .keep = c("all", "used", "unused", "none"),
  .before = NULL,
  .after = NULL
)

Arguments

.data

An object with the data.

...

Name-value pairs.

.keep, .before, .after

Use to control which columns are retained and how it is ordered in the output. See documentation of dplyr::mutate for more information.

Value

Returns a data frame.

Details

If you are familiar with gene replication process then you can recall these functions in genetic terms; an amplified gene is a duplication of the original while a mutated gene modifies the original state.

Examples

df <- data.frame(x = 1:3, y = c("a", "b", "b")) amplify(df, z = nest_in(y, "a" ~ 5, "b" ~ 3))
#> x y z #> 1 1 a 1 #> 2 1 a 2 #> 3 1 a 3 #> 4 1 a 4 #> 5 1 a 5 #> 6 2 b 1 #> 7 2 b 2 #> 8 2 b 3 #> 9 3 b 1 #> 10 3 b 2 #> 11 3 b 3