In R, you can create a list of sets using the list function for the outer list and the unique function for the inner sets.
In this example,
set1
and set2
using the unique
function.list_of_sets
using the list
function and initialize it with the inner sets.set1 <- unique(c(1, 2, 3))
set2 <- unique(c('a', 'b', 'c'))
list_of_sets <- list(set1, set2)
for (s in list_of_sets) {
print(s)
}
[1, 2, 3] ['a', 'b', 'c']
In this example,
list_of_empty_sets
using the list
function.unique
function.list_of_empty_sets <- list(unique(c()), unique(c()))
for (s in list_of_empty_sets) {
print(s)
}
integer(0) character(0)
In this tutorial, we learned How to create a List of Sets in R language with well detailed examples.