## Note: this can be done in a system-independent way
## by file.info()$isdir
if(.Platform$OS.type == "unix") {
system.test <- function(...) { system(paste("test", ...)) == 0 }
dir.exists <- function(dir)
sapply(dir, function(d) system.test("-d", d))
dir.exists(c(R.home(), "/tmp", "~", "/NO")) # > T T T F
}
Run the code above in your browser using DataLab