2018-10-19
阅读量:
1393
R中的路径设置
1、使用getwd()函数来显示当前工作目录。
> getwd()
[1] "C:/Users/Administrator/Documents"
2、使用setwd()函数更改当前目录。
> dir.create("E:/R_Files")
> setwd("E:/R_Files")
> getwd()
[1] "E:/R_Files"
注意:
(1) 函数setwd()不会自动创建一个不存在的目录。如果必要的话,可以使用函数dir.create()来创建新目录,然后使用setwd()将工作目录指向这个新目录。
(2)R里的dir.create()是不级联的,就是说一次只能创建有一个“/”的路径。如果需要两个“/”的路径(”E:/R_Files/R1”),就需要用dir.create()创建两次,然后文件才创建成功。再用setwd()去设置即可。
(3)函数setwd()是设置临时的工作路径(也就是说一旦你关闭了Rstudio后,工作目录又变回原来的工作目录)。
3、使用窗口永久更改工作目录。








评论(0)


暂无数据
推荐帖子
0条评论
0条评论
1条评论