Quantcast
Channel: How to check if object (variable) is defined in R? - Stack Overflow
Viewing all articles
Browse latest Browse all 8

Answer by Nirmal for How to check if object (variable) is defined in R?

$
0
0

If you don't want to use quotes, you can use deparse(substitute()) trick which I found in the example section of ?substitute:

is.defined <- function(sym) {  sym <- deparse(substitute(sym))  env <- parent.frame()  exists(sym, env)}is.defined(a)# FALSEa <- 10is.defined(a)# TRUE

Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>