This question already has an answer here:
Is there a way how to check if value exists in R environment and if == TRUE, assign this existing value otherwise assign something else?
In other words, I have nothing in my R right now and I created this if else statement.
test <- if_else(exists("my_value"), my_value, "my value missing, assigning this string")
Result of
exists("my_value")
is:
exists("my_value")
[1] FALSE
But once I run whole code I get this
Error in if_else(exists("my_value"), my_value, "my value missing, assigning this string") : object 'my_value' not found
Aucun commentaire:
Enregistrer un commentaire