[英]SublimeText and R: Setting Current File Directory
I have just started to use Sublime Text 2 to edit/write R codes and have installed the SublimeREPL package to execute R code within the editor. 我刚刚开始使用Sublime Text 2编辑/编写R代码,并安装了SublimeREPL包以在编辑器中执行R代码。 When I write a new R script it fails to read files in the SAME directory with the error:
当我编写新的R脚本时,它无法读取SAME目录中的文件,并显示以下错误:
Error in file(file, “rt”) : cannot open the connection
I checked getwd()
and it shows C:/windows/system32
which is probably the directory where sublime text is installed. 我检查了
getwd()
,它显示了C:/windows/system32
,这可能是安装了sublime文本的目录。
Is there a way to set the current working directory to the location of the current file. 有没有一种方法可以将当前工作目录设置为当前文件的位置。 This can be easily done in RStudio with
Session > setwd > source file location
. 在RStudio中,可以通过
Session > setwd > source file location
轻松完成此操作。
I can use the full path of the data file as a workaround, but I think that is not a convenient solution. 我可以使用数据文件的完整路径作为解决方法,但是我认为这不是一个方便的解决方案。
Any help would be greatly appreciated. 任何帮助将不胜感激。
I would check again whether the settings of SUBLIMERepl are configured correctly : 我将再次检查SUBLIMERepl的设置是否配置正确:
Open Preferences > Package Settings > SublimeREPL > Settings - Default
copy all the text 复制所有文字
then open Preferences > Package Settings > SublimeREPL > Settings - User
然后打开
Preferences > Package Settings > SublimeREPL > Settings - User
overwrite and paste the text there 覆盖并粘贴文本
Restart Sublime 重新启动崇高
When I then open tools > SublimeREPL > R
, I can setwd()
as usual. 然后,当我打开
tools > SublimeREPL > R
,可以像往常一样设置setwd()
。 The default getwd()
returned " /
" for me. 默认的
getwd()
为我返回了“ /
”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.