expand.grid(list.1, list.b) gives the desired result in the data.frame structure. This is usually the most useful format for working with data in R. However, you can get the exact structure that you request (save the order) with a call to apply and lapply :
result.df <- expand.grid(list.a, list.b) result.list <- lapply(apply(result.df, 1, identity), unlist)
If you want this list to be ordered by the first element:
result.list <- result.list[order(sapply(result.list, head, 1))]
source share