How to get all possible subsets of a character vector in R?

Viewed 1843

Having the following vector:

c("test1","test2","test3")

I am trying to get a list or data frame containing the following entries:

"test1" "test2" "test3"
"test1" "test2" NA
"test1" NA "test3"
"test1"  NA NA
NA  "test2" "test3"
NA  "test2" NA
NA  NA "test3"

The goal would be to get all possible subsets while the order doesn't matter, that is "text1" "text2" NA is equivalent to "text2" "text1" NA. I very much appreciate any help!

3 Answers
Related