Learn R Programming

RxODE (version 1.1.5)

rxExpandGrid: Faster expand.grid

Description

Only support x and y as characters right now

Usage

rxExpandGrid(x, y, type = 0L)

Arguments

x

first element (must be character)

y

second element (must be character)

type

Internal type=0L is traditional expand grid and type=1L is jacobian expand grid (adds symbols)

Value

Expand grid

Examples

Run this code
# NOT RUN {
##
rxExpandGrid(letters, letters)

## Another fast method; See
## https://stackoverflow.com/questions/10405637/use-outer-instead-of-expand-grid

expand.grid.jc <- function(seq1, seq2) {
  cbind(
    Var1 = rep.int(seq1, length(seq2)),
    Var2 = rep.int(seq2, rep.int(length(seq1), length(seq2)))
  )
}
# }
# NOT RUN {
microbenchmark::microbenchmark(rxExpandGrid(letters, letters), expand.grid.jc(letters, letters))
# }

Run the code above in your browser using DataLab