# This is only useful from within RStudio # editcode <- function(filename, dir, ...){ if (missing(dir)) dir <- getwd() file <- file.path(dir, filename, ...) if (file.exists(file)) { file.edit(file) } else { file.choose() } } # # Check that a variable is defined # (from stackoverflow # https://stackoverflow.com/questions/9368900/how-to-check-if-object-variable-is-defined-in-r # ) # is.defined <- function(sym) { sym <- deparse(substitute(sym)) env <- parent.frame() exists(sym, env) }