expand.grid for data.frames. Create a data frame from all combinations of the supplied data frames.

e_expand_grid_df(...)

Arguments

...

a list of data.frames

Value

A data frame containing one block of rows for each combination of the supplied data frames. The last data frames vary fastest. The columns retain their original names except for identical names in different data frames, in which case the suffix ".x", ".y", etc., are added in the returned data frame but may not be unique.

Examples

df1 <- data.frame(A = 1:3, B = 11:13)
df2 <- data.frame(C = 51:52, D = c("Y", "N"))
df3 <- data.frame(E = c("+", "-"))
e_expand_grid_df(df1, df2, df3)
#>    A  B  C D E
#> 1  1 11 51 Y +
#> 2  2 12 51 Y +
#> 3  3 13 51 Y +
#> 4  1 11 52 N +
#> 5  2 12 52 N +
#> 6  3 13 52 N +
#> 7  1 11 51 Y -
#> 8  2 12 51 Y -
#> 9  3 13 51 Y -
#> 10 1 11 52 N -
#> 11 2 12 52 N -
#> 12 3 13 52 N -