file.create(...) file.exists(...) file.remove(...) file.rename(from, to) file.append(file1, file2) file.copy(from, to, overwrite=FALSE) dir.create(path, showWarnings=TRUE, recursive=FALSE)
... arguments are concatenated to form one vector
of character values.
TRUE, the destination file(s) will be
overwritten if they exist.
TRUE warnings on directory creation are show.
TRUE all elements in
path
will be created if they do not already exist.
TRUE
indicates a successful operation for that element.
file.create creates files with the specified names.
If the file already exists, it is truncated to length zero.
file.exists returns a logical vector the length of the combined
arguments that is
TRUE if that file exists.
file.remove removes the specified files.
file.rename renames the single file given by
from
to the name given in
to.
file.append appends the contents of the files given in
file2
to the files given in
file1.
file.copy copies the files given by
from
to the names given in
to.
The
to argument can specify a single existing directory.
dir.create creates the single directory unless
recursive is
TRUE, then all necessary
directories specified in
path are created.
tfile1 <- tempfile("a")
tfile2 <- tempfile("b")
tfile3 <- tempfile("c")
cat("This is file 1\n", file=tfile1)
cat("This is file 2\n", file=tfile2)
file.append(tfile1, tfile2)
file.copy(tfile1, tfile3)
file.remove(tfile1)
file.exists(tfile1)
tdir <- tempfile("d")
dir.create(tdir)
file.copy(c(tfile2, tfile3), tdir)
list.files(tdir)
# Clean up:
unlink(c(tfile1, tfile2, tfile3, tdir))