rm(list = ls())

#Create a Data Frame from All Combinations of Factor Variables
list_1 <- list(height = seq(1, 2, 1), weight = c("A","B"),
     sex = c("Male","Female"))
list_1
## $height
## [1] 1 2
## 
## $weight
## [1] "A" "B"
## 
## $sex
## [1] "Male"   "Female"
expand.grid(list_1)
##   height weight    sex
## 1      1      A   Male
## 2      2      A   Male
## 3      1      B   Male
## 4      2      B   Male
## 5      1      A Female
## 6      2      A Female
## 7      1      B Female
## 8      2      B Female
#Generate All Combinations of n Elements, Taken m at a Time
combn(x = c("A","B","C"), m = 2)
##      [,1] [,2] [,3]
## [1,] "A"  "A"  "B" 
## [2,] "B"  "C"  "C"
combn(x = c("A","B","C","D"), m = 3)
##      [,1] [,2] [,3] [,4]
## [1,] "A"  "A"  "A"  "B" 
## [2,] "B"  "B"  "C"  "C" 
## [3,] "C"  "D"  "D"  "D"