SublimeText 和 R:设置当前文件目录 [英] SublimeText and R: Setting Current File Directory

查看:46
本文介绍了SublimeText 和 R:设置当前文件目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 Sublime Text 2 来编辑/编写 R 代码并安装了 SublimeREPL 包来在编辑器中执行 R 代码.当我编写一个新的 R 脚本时,它无法读取 SAME 目录中的文件并显示错误:

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. When I write a new R script it fails to read files in the SAME directory with the error:

Error in file(file, "rt") : cannot open the connection

我检查了 getwd(),它显示 C:/windows/system32 这可能是安装 sublime text 的目录.

I checked getwd() and it shows C:/windows/system32 which is probably the directory where sublime text is installed.

有没有办法将当前工作目录设置为当前文件的位置.这可以在 RStudio 中使用 Session > 轻松完成.设置>源文件位置.

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.

我可以使用数据文件的完整路径作为解决方法,但我认为这不是一个方便的解决方案.

I can use the full path of the data file as a workaround, but I think that is not a convenient solution.

任何帮助将不胜感激.

推荐答案

我会再次检查 SUBLIMERepl 的设置是否正确配置:

I would check again whether the settings of SUBLIMERepl are configured correctly :

Open Preferences > Package Settings > SublimeREPL > Settings - Default 

复制所有文本

然后打开 Preferences >包设置 >崇高的REPL设置 - 用户

覆盖并粘贴文本

重启 Sublime

当我打开 tools >崇高的REPLR,我可以像往常一样setwd().默认的 getwd() 为我返回了/".

When I then open tools > SublimeREPL > R, I can setwd() as usual. The default getwd() returned "/" for me.

这篇关于SublimeText 和 R:设置当前文件目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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