How to check if an R environment exists
r
Solution
`exists` takes a character argument:
exists("storage")
Though note that this will return `TRUE` even if `storage` is not an environment. You will either have to check it using `is.environment` as Señor O suggests, or pass `mode="environment"`:
exists("storage", mode="environment")
Problem
I would like to check if an R environment exists, but the standard exists() function doesn't accept an environment as argument: ``` storage <- new.env(parent = emptyenv()) storage #<environment: 0xeb3195c> exists(storage) #Error in exists(storage) : invalid first argument ``` Is there any way of checking if an environment has been defined? Or is it an intrinsically wrong thing to do? Thanks!