SublimeText and R: Setting Current File Directory

2019-03-06 05:49发布

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

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

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.

Any help would be greatly appreciated.

1条回答
孤傲高冷的网名
2楼-- · 2019-03-06 06:15

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

Open Preferences > Package Settings > SublimeREPL > Settings - Default 

copy all the text

then open 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. The default getwd() returned "/" for me.

查看更多
登录 后发表回答