
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
)
newFilename returns the input with an added "_n" in the filename for each file that already existed.
Char (vector): file name(s).
Logical (vector, recycled): Ignore file? DEFAULT: FALSE
Logical (vector, recycled): overwrite file? DEFAULT: FALSE
Logical: Message about ignored files? DEFAULT: TRUE
Char: strings to append after traceback / message / filenames. DEFAULT: "", "\n ", ""
Logical: Suppress messages about creating file(s)? DEFAULT: FALSE
Integer: Number of filenames printed in messages before they get truncated with message "(and xx more)". DEFAULT: 3
Berry Boessenkool, berry-b@gmx.de, Oct 2016 + Jan 2017
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
Run the code above in your browser using DataLab