
Input and Output in R 129
In the example below, we demonstrate the use of some of these functions.
We do most of the reading and writing to R temporary directory.
> newDir = file.path(tempdir(), "newDir")
> newDir
[1] "/tmp/RtmpHPmzRh/newDir"
> newFile = file.path(newDir, "blah")
> newFile
[1] "/tmp/RtmpHPmzRh/newDir/blah"
> dir.create(newDir)
> file.create(newFile)
[1] TRUE
> file.exists(newDir, newFile)
[1] TRUE TRUE
> unlink(newDir, recursive = TRUE)
Setting the recursive argument to unlink to TRUE is needed to remove non-
empty directories. If this argument has its default value, FALSE, then the
command would fail to remove a non-empty directory the same ...