R 目录及文件操作

获取当前路径  getwd()

切换当前路径  setwd()

返回上一级目录  setwd(dirname(getwd()))

获取文件所在路径  dirname()

查看当前目录的子目录  list.dirs()

查看当前目录的子目录和文件 dir()

查看指定目录的子目录及文件  dir(path="a/b/c/d")

查看当前目录的信息  file.info(".")

检查目录或文件是否存在  file.exists("./other")

判断是文件还是目录  file_test("-f", "abc")    file_test("-d", "abc")

创建目录  dir.create("abc")

创建多级目录  dir.create("a/b/c", recursive=TRUE)

创建空文件 file.create("abc.txt")

删除文件或目录 unlink("abc")

删除文件  file.remove("abc.txt")

文件或者目录重命名  file.rename("abc", "def")

复制文件  file.copy(from, to)

通过系统命令查看目录结构  system("tree")

 

posted on 2019-07-06 17:26  0820LL  阅读(1018)  评论(0编辑  收藏  举报

导航