list.expand: Create a list from all combinations of factors

Description Usage Arguments Value Examples

View source: R/list.expand.R

Description

Create a list from all combinations of the supplied vectors or lists, extending the functionality of expand.grid from data frame to list.

Usage

1

Arguments

...

vectors or lists

Value

A list of all combinations of the supplied vectors or lists.

Examples

1
2
3
4
5
list.expand(x=1:10, y=c("a","b","c"))
list.expand(x=list(c(1,2), c(2,3)), y = c("a","b","c"))
list.expand(
  a=list(list(x=1,y="a"), list(x=2, y="b")),
  b=list(c("x","y"), c("y","z","w")))

Example output

[[1]]
[[1]]$x
[1] 1

[[1]]$y
[1] "a"


[[2]]
[[2]]$x
[1] 2

[[2]]$y
[1] "a"


[[3]]
[[3]]$x
[1] 3

[[3]]$y
[1] "a"


[[4]]
[[4]]$x
[1] 4

[[4]]$y
[1] "a"


[[5]]
[[5]]$x
[1] 5

[[5]]$y
[1] "a"


[[6]]
[[6]]$x
[1] 6

[[6]]$y
[1] "a"


[[7]]
[[7]]$x
[1] 7

[[7]]$y
[1] "a"


[[8]]
[[8]]$x
[1] 8

[[8]]$y
[1] "a"


[[9]]
[[9]]$x
[1] 9

[[9]]$y
[1] "a"


[[10]]
[[10]]$x
[1] 10

[[10]]$y
[1] "a"


[[11]]
[[11]]$x
[1] 1

[[11]]$y
[1] "b"


[[12]]
[[12]]$x
[1] 2

[[12]]$y
[1] "b"


[[13]]
[[13]]$x
[1] 3

[[13]]$y
[1] "b"


[[14]]
[[14]]$x
[1] 4

[[14]]$y
[1] "b"


[[15]]
[[15]]$x
[1] 5

[[15]]$y
[1] "b"


[[16]]
[[16]]$x
[1] 6

[[16]]$y
[1] "b"


[[17]]
[[17]]$x
[1] 7

[[17]]$y
[1] "b"


[[18]]
[[18]]$x
[1] 8

[[18]]$y
[1] "b"


[[19]]
[[19]]$x
[1] 9

[[19]]$y
[1] "b"


[[20]]
[[20]]$x
[1] 10

[[20]]$y
[1] "b"


[[21]]
[[21]]$x
[1] 1

[[21]]$y
[1] "c"


[[22]]
[[22]]$x
[1] 2

[[22]]$y
[1] "c"


[[23]]
[[23]]$x
[1] 3

[[23]]$y
[1] "c"


[[24]]
[[24]]$x
[1] 4

[[24]]$y
[1] "c"


[[25]]
[[25]]$x
[1] 5

[[25]]$y
[1] "c"


[[26]]
[[26]]$x
[1] 6

[[26]]$y
[1] "c"


[[27]]
[[27]]$x
[1] 7

[[27]]$y
[1] "c"


[[28]]
[[28]]$x
[1] 8

[[28]]$y
[1] "c"


[[29]]
[[29]]$x
[1] 9

[[29]]$y
[1] "c"


[[30]]
[[30]]$x
[1] 10

[[30]]$y
[1] "c"


[[1]]
[[1]]$x
[1] 1 2

[[1]]$y
[1] "a"


[[2]]
[[2]]$x
[1] 2 3

[[2]]$y
[1] "a"


[[3]]
[[3]]$x
[1] 1 2

[[3]]$y
[1] "b"


[[4]]
[[4]]$x
[1] 2 3

[[4]]$y
[1] "b"


[[5]]
[[5]]$x
[1] 1 2

[[5]]$y
[1] "c"


[[6]]
[[6]]$x
[1] 2 3

[[6]]$y
[1] "c"


[[1]]
[[1]]$a
[[1]]$a$x
[1] 1

[[1]]$a$y
[1] "a"


[[1]]$b
[1] "x" "y"


[[2]]
[[2]]$a
[[2]]$a$x
[1] 2

[[2]]$a$y
[1] "b"


[[2]]$b
[1] "x" "y"


[[3]]
[[3]]$a
[[3]]$a$x
[1] 1

[[3]]$a$y
[1] "a"


[[3]]$b
[1] "y" "z" "w"


[[4]]
[[4]]$a
[[4]]$a$x
[1] 2

[[4]]$a$y
[1] "b"


[[4]]$b
[1] "y" "z" "w"

rlist documentation built on Sept. 5, 2021, 5:30 p.m.