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