newFilename | R Documentation |
Check if files already exist and append _1
or _2
, etc to the filename if needed,
thereby giving useful messages.
newFilename(
filename,
ignore = FALSE,
overwrite = FALSE,
tellignore = TRUE,
pre = "",
mid = "\n",
end = "",
quiet = FALSE,
ntrunc = 3
)
filename |
Char (vector): file name(s). |
ignore |
Logical (vector, recycled): Ignore file? DEFAULT: FALSE |
overwrite |
Logical (vector, recycled): overwrite file? DEFAULT: FALSE |
tellignore |
Logical: Message about ignored files? DEFAULT: TRUE |
pre , mid , end |
Char: strings to append after traceback / message / filenames. DEFAULT: "", "\n ", "" |
quiet |
Logical: Suppress messages about creating file(s)? DEFAULT: FALSE |
ntrunc |
Integer: Number of filenames printed in messages before they get truncated with message "(and xx more)". DEFAULT: 3 |
newFilename returns the input with an added "_n" in the filename for each file that already existed.
Berry Boessenkool, berry-b@gmx.de, Oct 2016 + Jan 2017
file.exists
fns <- c("dummy1", "dummy2.txt", "berryFunctions.Rproj",
"README.md", "dummy2.dummy", "DESCRIPTION", "dummy4.R", "dummy5")
newFilename(fns)
newFilename(fns, ignore=TRUE)
newFilename(fns, ignore=rep(c(TRUE,FALSE), each=4) )
newFilename(fns, ignore=rep(c(TRUE,FALSE), each=4), tellignore=FALSE)
newFilename(fns, ntrunc=2)
newFilename(fns, overwrite=TRUE, ign=c(TRUE,TRUE,rep(FALSE,6)))
newFilename("README.md")
newFilename("dummy", mid=" ") # no line break
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.