use*_*666 32 directory r rstudio
我咨询了http://www.rstudio.com/ide/docs/using/workspaces并尝试了setwd
代码,然后单击更多 - >设置为工作目录选项.但是,下次我关闭并打开RStudio时,它并没有将我的目录更改为我想要的目录.
如何设置目录,以便每次打开RStudio时都没有更改它?
谢谢.
小智 7
在适用于 Windows (Win7) 的 R (3.1.2) 上,我执行了以下操作并且成功了:
1- 在我的情况下,导航到 R 文件夹中的文件“Rprofile.site”:C:\Program Files\R\etc\Rprofile.site 其中“etc”确实是子文件夹的给定名称。
2- 在具有管理员权限的文本编辑器中打开文件 Rprofile.site(我在记事本中做过)并在文件顶部的第一行插入以下命令,该命令告诉 R 在启动时设置工作目录到您在括号内指定的 PATH (确保您对 Windows 使用双反斜杠“\\”!),在我的情况下:
setwd("C:\\Users\\FWA\\Documents\\PROGR&MOOCS\\R_coursera")
3-保存文件,然后看起来像这样:
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()
Run Code Online (Sandbox Code Playgroud)
4- 启动 R-Studio 并在命令提示符下键入“获取工作目录”命令,如下所示:
getwd()
5- 您的 R-Studio 现在应该返回您之前指定的工作目录路径。在我的情况下,R 返回这个:
[1] "C:/Users/FWA/Documents/PROGR&MOOCS/R_coursera"
6-你完成了。
注意:这会更改 R 环境的工作目录,而不仅仅是 R-Studio。
小智 5
会话->设置工作目录->选择目录...或快捷键(Ctrl + Shift + H)
或者,您可以在控制台上设置工作目录,例如= setwd(“ C:/ Users / burak / Desktop / R”)