永久修改R语言工作目录

默认情况下R语言工作目录每次启动都需要重新设定,为了省事,我们可以把它用命令方式写入到配置文件中,这样每次启动时可以自动设置。

具体方法:

Setting the working directory in R permanently
1)The getwd() command gives the current working directory for R.
The  setwd() sets the working directory
2)Locate the Rprofile.site file.
•It should be in C:\Program Files\R\R-\etc\Rprofile.site (onWindows).•
I’m not sure where this is on a Mac
3)Add setwd() to the end of theRprofile.sitefile
•Open the Rprofile.site file on text editor (notepad)
•Add the line below to the end of the

找到这个文件  Rprofile.sitefile  文件最后增加新行,然后输入

setwd("")     //关键是 这一行。

重新打开R就OK

•My Rprofile.sitefilelooks like this:
# 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)})
setwd("C:\\Programming\\R\\Data\\RegressionClassData")
•NOTICE THE EXTRA EMPTY LINE AFTER THE setwd() COMMAND.
•Save and close this file
•Restart the R GUI
•Typing getwd() on the command line shouldnowreturn the path that wasset in the previous steps.


你可能感兴趣的:(数据挖掘技术)