简体   繁体   中英

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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM