如何使R将您的工作目录识别为它的工作目录? [英] How to get R to recognize your working directory as its working directory?

查看:130
本文介绍了如何使R将您的工作目录识别为它的工作目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在多台计算机上的Windows下使用R.

I use R under Windows on several machines.

我知道您可以像这样在R脚本中设置工作目录

I know you can set the working directory from within an R script, like this

setwd("C:/Documents and Settings/username/My Documents/x/y/z")

...但是这破坏了脚本的可移植性.还必须反转所有斜杠(因为Windows会给您提供反斜杠),这也很烦人

... but then this breaks the portability of the script. It's also annoying to have to reverse all the slashes (since Windows gives you backslashes)

是否可以在特定的工作目录中启动R,这样您就不必在脚本级别执行此操作了?

Is there a way to start R in a particular working directory so that you don't need to do this at the script level?

推荐答案

您应将快捷方式复制到R(R.lnk文件)到所需文件夹.然后在属性"(鼠标右键->最后一个选项)中,删除第二个选项卡中的开始于..."字段中的任何内容(快捷方式"?).如果使用此快捷方式工作目录启动R,则该目录就是该快捷方式所在的地方.

You should copy shortcut to R (R.lnk file) to desire folder. Then in "Properties" (right mouse button -> last option) delete anything in field "Start in..." in second tab ("Shortcut"?). If you start R with this shortcut working directory will be that one where the shortcut is.

我没有英文版Windows,所以我不确定字段名称,但是应该很容易找到它们.

I don't have english version of Windows so I'm not sure about field names, but they should be easy to find.

类似的问题在R-windows-faq中:

Similar questions were in R-windows-faq:

2.5如何我要运行它吗?

2.14什么是HOME和工作目录?

在2.14中提到

工作目录是从其中启动Rgui或Rterm的目录,除非在快捷方式属性的开始于"字段中指定了快捷方式时使用了该快捷方式.

The working directory is the directory from which Rgui or Rterm was launched, unless a shortcut was used when it is given by the `Start in' field of the shortcut's properties.

这篇关于如何使R将您的工作目录识别为它的工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆