Checks and creates a directory recursively automatically.
Examples
dir <- file.path(tempdir2(), c("aaa", "bbb"))
#> Error in vapply(X = X, FUN = FUN, FUN.VALUE = logical(1L), ..., USE.NAMES = useNames): formal argument "USE.NAMES" matched by multiple actual arguments
dir.exists(dir)
#> Error in dir.exists(dir): invalid filename argument
dir <- initDir(dir)
#> Error in stop(simpleError(message = msg, call = if (p) { sys.call(p)})): Assert failure.
#> [1] isCharacter(dir) is not TRUE.
#> Cause: `function` is not character.
dir.exists(dir)
#> Error in dir.exists(dir): invalid filename argument
print(dir)
#> function (path = ".", pattern = NULL, all.files = FALSE, full.names = FALSE,
#> recursive = FALSE, ignore.case = FALSE, include.dirs = FALSE,
#> no.. = FALSE, fixed = FALSE)
#> .Internal(list.files(path, pattern, all.files, full.names, recursive,
#> ignore.case, include.dirs, no.., fixed))
#> <bytecode: 0xb54c36190>
#> <environment: namespace:base>
unlink2(dir)
#> Error in file.exists(x): invalid 'file' argument