Faster expand.grid
Only support x and y as characters right now
rxExpandGrid(x, y, type = 0L)
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)Expand grid
## 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))) ) } microbenchmark::microbenchmark(rxExpandGrid(letters, letters), expand.grid.jc(letters, letters))
Matthew Fidler
Useful links