Check whether a Vector Object is Empty in R (Example Code)

In this tutorial you’ll learn how to evaluate whether a vector object is empty in R programming.

Creation of Example Data

x <- vector()                      # Constructing an empty example vector
x
# logical(0)

Example: Checking whether Vector is Empty Using the length() Function

length(x) == 0                     # Return indicator if vector is empty
# [1] TRUE

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top