Check if an Object of the Specified Name is Defined or not in R Programming – exists() Function
exists() function in R Programming Language is used to check if an object with the names specified in the argument of the function is defined or not. It returns TRUE if the object is found.
- name: Name of the Object to be searched
exists() Function in R Language Example
Example 1: Apply exists() Function to variable
 TRUE  TRUE  FALSE
Example 2: Apply exists() Function to Vector
In the above examples, it can be seen that when there was no object named “Hello” defined in the first code, the exists() function returned FALSE, whereas after the declaration of the “Hello” Object, the exists() function returned TRUE. This means that the exists() function checks for pre-defined and user-defined, objects.
Example 3: Check if Variable in Data Frame is Defined
friend_id friend_name 1 1 Sachin 2 2 Sourav 3 3 Dravid 4 4 Sehwag 5 5 Dhoni TRUE