tidyr (version 0.2.0)

expand: Expand data frame to include all combinations of levels.

Description

Expand data frame to include all combinations of levels.

Usage

expand(data, ...)

Arguments

data
A data frame
...
Specification of columns to expand. These can either be bare column names, or transformations of a column.

See Also

expand_ for a version that uses regular evaluation and is suitable for programming with.

Examples

Run this code
expand(mtcars, vs, cyl)
expand(mtcars, cyl, mpg = seq_range(mpg, 2))
expand(mtcars, cyl, mpg = seq_range(mpg, 5))

df <- data.frame(a = c(1, 2, 5), b = c(3, 5, 3), c = c(1, 2, 3))
expand(df)
expand(df, a, b)
expand(df, a, c)
expand(df, b, c)

Run the code above in your browser using DataCamp Workspace