amplify: Amplify the data frame with a given structure

Description Usage Arguments Details Value Examples

View source: R/amplify.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
amplify(.data, ...)

## S3 method for class '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.

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.

Value

Returns a data frame.

Examples

1
2
3
df <- data.frame(x = 1:3, y = c("a", "b", "b"))
amplify(df, z = nest_in(y, "a" ~ 5,
                           "b" ~ 3))

nestr documentation built on March 16, 2021, 9:06 a.m.