7

I am trying to use Sublime Text 2 as an interface to the statistics software R [update/edit: Solved!].

On Windows, I have tried the following:

  1. Installed R Tools. Turned out to be for Macintosh 64 only.

  2. Tried to program custom build file. Failed: no output returned.

    {
    "cmd": "C:/Program Files/R/R-2.9.2/bin/R.exe --no-save $File"
    }
    
  3. Installed SublimeREPL. Failed: R menu option disabled...

  4. [update/edit] Tried this (see wuub's reply):

    {
        "default_extend_env": {"PATH": "{PATH};C:\\Program Files\\R\\R-2.9.2\\bin"}  
    }
    
noumenal
  • 1,077
  • 2
  • 16
  • 36

4 Answers4

9

Open SublimeREPL's user settings like this: Preferences -> Package Settings -> SublimeREPL -> Settings - User

there set default_extend_path to point to your R installation:

{
    "default_extend_env": {"PATH": "{PATH};C:\\Program Files\\R\\R-2.14.2\\bin\\i386"}  
}

Running Tools -> SublimeREPL -> R should launch REPL as expected.

Wojciech Bederski
  • 3,852
  • 1
  • 25
  • 28
  • Thanks. I gave this a try, saved, and restarted Sublime text 2. However, all items are still greyed out in the Sublime REPLmenu. I cannot run R at all. – noumenal Apr 25 '12 at 20:45
  • 1
    Try Tools -> Command Palette and type "SublimeREPL: R". I cannot think of anything that would cause menu items to be disabled, it seems something is wrong with your ST2 installation. – Wojciech Bederski Apr 25 '12 at 21:14
  • Install seems to be corrupt. Cannot find the command in the Command Palette. – noumenal Apr 26 '12 at 09:22
  • 1
    Great. There are still some unsolved problems with SublimeREPL & R (see: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=5802) but at least for some it seems to be usable. – Wojciech Bederski Apr 26 '12 at 09:34
2

For windows system you can add a new build for R (Tools -> Build System -> New Build System) and put the following lines. Modify the path according to your R installation directory.

{"cmd": ["Rscript.exe", "$file"],
"path": "C:\\Program Files\\R\\R-2.15.2\\bin\\x64\\",
"selector": "source.r"}

You can execute the entire file by pressing ctrl+B instead of starting SublimeREPL.

Feng Mai
  • 2,749
  • 1
  • 28
  • 33
1

The build system value needs to be an array so you want;

{
  "cmd": ["C:/Program Files/R/R-2.9.2/bin/R.exe", "--no-save", "$File"]
}

https://docs.sublimetext.io/guide/usage/build-systems.html#file-format

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
Alex K.
  • 171,639
  • 30
  • 264
  • 288
0

For linux users, take a look:

Sublime Text 2 R build System

It supports multi selection and interactive R sessions.

Community
  • 1
  • 1
cpicanco
  • 205
  • 5
  • 19
  • This build uses xsel and xdotool. Autohotkey (AHK) could be an alternative for windows users. – cpicanco Jan 21 '15 at 02:50
  • Have you done the configuration steps? See http://stackoverflow.com/questions/29732597/sublimetext-and-r-setting-current-file-directory/29733166#29733166 – TinaW Apr 25 '15 at 11:23