expand_grid: Similar to expand.grid but with Sequences Reversed and...

Description Usage Arguments Value Examples

View source: R/expand_grid.R

Description

Loops over the last argument, then the second-last, and so on. It should be faster than expand.grid.

Usage

1
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

1
2
3
4
5
6
7
# 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")))

dvmisc documentation built on Dec. 18, 2019, 1:35 a.m.