expand_grid {dvmisc} | R Documentation |
Similar to expand.grid but with Sequences Reversed and Ability to Treat Variables as Sets
Description
Loops over the last argument, then the second-last, and so on. It should be
faster than expand.grid
.
Usage
expand_grid(..., together = NULL)
Arguments
... |
Vectors you want all combinations of. |
together |
Data frame of vectors, where each row is a set of parameter values that are always kept together. |
Value
Data table.
Examples
# Simple example of expand.grid vs. expand_grid
expand.grid(x = c("a", "b", "c"), y = c(1, 2), z = c(TRUE, FALSE))
expand_grid(x = c("a", "b", "c"), y = c(1, 2), z = c(TRUE, FALSE))
# How to keep certain variables together
expand_grid(x = 1: 5,
together = data.frame(y = c("1a", "2a"), z = c("1b", "2b")))
[Package dvmisc version 1.1.4 Index]