The function creates a tibble with two columns, xvar
and yvar
, whose
rows enumerate all combinations of column names specified in the xvars
and yvars
argument. The column names to create the combinations from are
specified using a tidyselect expression (see
tidyselect syntax).
Arguments
- x
either a data frame or a matrix
- xvars
a tidyselect expression (see tidyselect syntax) specifying the columns of
x
, whose names will be used as a domain for combinations use at the first place (xvar)- yvars
a tidyselect expression (see tidyselect syntax) specifying the columns of
x
, whose names will be used as a domain for combinations use at the second place (yvar)
Value
a tibble with two columns (xvar
and yvar
) with rows enumerating
all combinations of column names specified by tidyselect expressions
in xvars
and yvars
arguments.
Examples
var_grid(CO2)
#> # A tibble: 10 × 2
#> xvar yvar
#> <chr> <chr>
#> 1 Plant Type
#> 2 Plant Treatment
#> 3 Plant conc
#> 4 Plant uptake
#> 5 Type Treatment
#> 6 Type conc
#> 7 Type uptake
#> 8 Treatment conc
#> 9 Treatment uptake
#> 10 conc uptake
var_grid(CO2, xvars = Plant:Treatment, yvars = conc:uptake)
#> # A tibble: 6 × 2
#> xvar yvar
#> <chr> <chr>
#> 1 Plant conc
#> 2 Plant uptake
#> 3 Type conc
#> 4 Type uptake
#> 5 Treatment conc
#> 6 Treatment uptake