How to check if object (variable) is defined in R?

r

Solution

You want `exists()`:

R> exists("somethingUnknown")
[1] FALSE
R> somethingUnknown <- 42
R> exists("somethingUnknown")
[1] TRUE
R> 

Problem

I'd like to check if some variable is defined in R - without getting an error. How can I do this? My attempts (not successful): ``` > is.na(ooxx) Error: object 'ooxx' not found > is.finite(ooxx) Error: object 'ooxx' not found ``` Thanks!

Original source

Related problems