To check if a Set is empty in R, you can use the length function or the is_empty function.
In this example,
# Define set
mySet <- c('apple', 'banana', 'orange')
# Check if set is empty using length function
if (length(mySet) == 0) {
print('Set is empty')
} else {
print('Set is not empty')
}
Set is not empty
In this example,
# Define set
mySet <- c('apple', 'banana', 'orange')
# Check if set is empty using is_empty function
if (is_empty(mySet)) {
print('Set is empty')
} else {
print('Set is not empty')
}
Set is not empty
In this tutorial, we learned How to check if a Set is Empty in R language with well detailed examples.