checkFile | R Documentation |
check whether files exist and give a useful error/warning/message
checkFile(file, warnonly = FALSE, trace = TRUE, pwd = TRUE, nprint = 2)
file |
Filename(s) as character string to be checked for existence. |
warnonly |
Logical: Only issue a |
trace |
Logical: Add function call stack to the message? DEFAULT: TRUE |
pwd |
Logical: Print working directory in message? DEFAULT: TRUE |
nprint |
Integer: number of filenames to be printed. The rest is abbreviated with (and n others). DEFAULT: 2 |
TRUE/FALSE, invisibly
Berry Boessenkool, berry-b@gmx.de, May 2016
file.exists
is.error( checkFile("FileThatDoesntExist.txt") )
checkFile("FileThatDoesntExist.txt", warnonly=TRUE)
checkFile("FileThatDoesntExist.txt", warnonly=TRUE, trace=FALSE)
checkFile("./", warnonly=TRUE)
checkFile(c("./",".//"), warnonly=TRUE)
## Not run: ## Excluded from CRAN checks because of file creation
# Vectorized:
file.create("DummyFile2.txt")
checkFile("DummyFile2.txt/")
checkFile(paste0("DummyFile",1:3,".txt"), warnonly=TRUE)
is.error(checkFile(paste0("DummyFile",1:3,".txt") ), TRUE, TRUE)
file.remove("DummyFile2.txt")
is.error(compareFiles("dummy.nonexist", "dummy2.nonexist"), TRUE, TRUE)
is.error(checkFile("dummy.nonexist"), TRUE, TRUE)
## End(Not run)
dingo <- function(k="brute.nonexist", trace=TRUE)
checkFile(k, warnonly=TRUE, trace=trace)
dingo()
dingo("dummy.nonexist")
upper <- function(h, ...) dingo(c(h, "dumbo.nonexist"), ...)
upper("dumbo2.nonexist")
upper(paste0("dumbo",2:8,".nonexist"))
upper(paste0("dumbo",2:8,".nonexist"), trace=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.