If I want to check the existence of a variable, I use
exists("variable")
In a script, I work on the fact that I sometimes run into the “index outside” problem after starting, and then my script stops. In the if statement, I would like to be able to check if the index is outside or not. If the result is yes, then run the alternate script world, and if not, then just continue the script as intended.
In my imagination, in the case of a list, it looks something like this:
if {subscriptOutofBounds(listvariable[[number]]) == TRUE) { ## execute this part of the code } else { ## execute this part }
Is there something similar in R?
source share