我参考了http://www.rstudio.com/ide/docs/using/workspaces,尝试使用setwd
命令,并点击“More-->Set as working directory”选项。但是,下次关闭并打开RStudio时,它没有将我的目录更改为我想要的目录。
我该如何设置目录,以便每次打开RStudio时无需更改它?
谢谢。
我参考了http://www.rstudio.com/ide/docs/using/workspaces,尝试使用setwd
命令,并点击“More-->Set as working directory”选项。但是,下次关闭并打开RStudio时,它没有将我的目录更改为我想要的目录。
我该如何设置目录,以便每次打开RStudio时无需更改它?
谢谢。
不确定这是否是您要查找的内容,但在“工具”|“全局选项”(alt-TG)下有一种设置默认目录的方法。
setwd("C:\\Users\\FWA\\Documents\\PROGR&MOOCS\\R_coursera")
# Things you might want to change
# options(papersize="a4")
# options(editor="notepad")
# options(pager="internal")
# set the default help type
# options(help_type="text")
options(help_type="html")
# set a site library
# .Library.site <- file.path(chartr("\\", "/", R.home()), "site-library")
# set a CRAN mirror
# local({r <- getOption("repos")
# r["CRAN"] <- "http://my.local.cran"
# options(repos=r)})
# Give a fortune cookie, but only to interactive sessions
# (This would need the fortunes package to be installed.)
# if (interactive())
# fortunes::fortune()
4- 打开R-Studio,在命令提示符下键入“get working directory”命令,格式如下:
getwd()
5- 现在,您的R-Studio应返回您之前指定的工作目录路径。在我的情况下,R返回以下内容:
[1] "C:/Users/FWA/Documents/PROGR&MOOCS/R_coursera"
6- 完成了。
注意:这将更改R环境的工作目录,而不仅仅是R-Studio。
会话 -> 设置工作目录 -> 选择目录 ... 或快捷键 (Ctrl+Shift+H)
或者您可以在控制台上设置您的工作目录,例如:setwd("C:/Users/burak/Desktop/R")
.Rprofile
或Rprofile.site
文件中,使用setwd()
函数。这样做后,每次启动 R 或 RStudio 时,它都会默认到该目录。 - hrbrmstr