In R, you can use the length()
function to check if a Set is not empty.
In this example,
set
and initialize it with some elements.length()
function on the Set set
to determine its length.# Initialize a Set
set <- c(1, 2, 3) # Or set <- numeric(0) for an empty Set
# Check if Set is not empty
if (length(set) > 0) {
print('The Set is not empty')
} else {
print('The Set is empty')
}
The Set is not empty
In this example,
emptySet
.length()
function on the Set emptySet
to determine its length.# Initialize an empty Set
emptySet <- numeric(0)
# Check if Empty Set is not empty
if (length(emptySet) > 0) {
print('The Set is not empty')
} else {
print('The Set is empty')
}
The Set is empty
In this tutorial, we learned How to check if a Set is Not Empty in R language with well detailed examples.