## Note: this can be done in a system-independent way
## by file.info()$isdir: see utils::file_test
if(.Platform$OS.type == "unix") {
system.test <- function(...) system(paste("test", ...)) == 0L
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