Examples for 'base::files'


File Manipulation

Aliases: files file.append file.copy file.create file.exists file.remove file.rename file.symlink file.link

Keywords: file

### ** Examples

## Don't show: 
oldwd <- setwd(tempdir())
## End(Don't show)
cat("file A\n", file = "A")
cat("file B\n", file = "B")
file.append("A", "B")
[1] TRUE
file.create("A") # (trashing previous)
[1] TRUE
file.append("A", rep("B", 10))
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
if(interactive()) file.show("A") # -> the 10 lines from 'B'
file.copy("A", "C")
[1] TRUE
dir.create("tmp")
file.copy(c("A", "B"), "tmp")
[1] TRUE TRUE
list.files("tmp") # -> "A" and "B"
[1] "A" "B"
setwd("tmp")
file.remove("A") # the tmp/A file
[1] TRUE
file.symlink(file.path("..", c("A", "B")), ".")
Warning in file.symlink(file.path("..", c("A", "B")), "."): cannot symlink
'../B' to './B', reason 'File exists'
[1]  TRUE FALSE
                     # |--> (TRUE,FALSE) : ok for A but not B as it exists already
setwd("..")
unlink("tmp", recursive = TRUE)
file.remove("A", "B", "C")
[1] TRUE TRUE TRUE
## Don't show: 
setwd(oldwd)
## End(Don't show)

[Package base version 4.2.3 Index]