expandGrid: Wrapper around expand.grid

View source: R/dataFrame.R

expandGridR Documentation

Wrapper around expand.grid

Description

Same as expand.grid but with stringsAsFactors = FALSE by default and with the values of the first argument being changed last, not first.

Usage

expandGrid(..., stringsAsFactors = FALSE)

Arguments

...

arguments passed to expand.grid, but in reversed order

stringsAsFactors

passed to expand.grid

Examples

persons <- c("Peter", "Paul", "Mary")
fruits <- c("apple", "pear")

# With expand.grid() the values of the first argument change first...
(grid_1 <- expand.grid(person = persons, fruit = fruits))

#... with expandGrid() they change last.
(grid_2 <- expandGrid(person = persons, fruit = fruits))

# With expand.grid() character strings are converted to factors by default...
str(grid_1)

# ... with expandGrid() character strings are not converted by default.
# Also, there is no attribute "out.attrs" as it is set by expand.grid().
str(grid_2)


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.