new_dir <- function(..., create = TRUE, safe = TRUE)
{
path <- file.path(...)
if (nchar(file_ext(path)) > 0L) {
stop("'path' points to a specific file, ",
"not to a directory.", call. = FALSE)
}
if (create && safe && !dir.exists(dirname(path))) {
stop("'safe' is TRUE but multiple dirs in 'path' must be created.",
call. = FALSE)
}
structure(
path,
created = if (create) dir.create(path, FALSE, !safe) else FALSE,
exists = dir.exists(path),
class = "dir")
}
dir_new <- function(...) new_dir(...)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.