How to check if an array is empty in R programming language?

In R programming, you can use the length() function to check if an array is empty. The function will return 0 if the array is empty, otherwise it will return the length of the array.

For example:

my_array <- c()

if (length(my_array) == 0) {
  print("Array is empty")
} else {
  print("Array is not empty")
}

In the example above, if the my_array array is empty, it will output “Array is empty”, otherwise it will output “Array is not empty”.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds