Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 2 and R

Tags:

r

sublimetext2

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"}  
    }
    
like image 290
noumenal Avatar asked Apr 20 '12 14:04

noumenal


3 Answers

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.

like image 90
Wojciech Bederski Avatar answered Sep 21 '22 08:09

Wojciech Bederski


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.

like image 29
Feng Mai Avatar answered Sep 20 '22 08:09

Feng Mai


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

like image 23
Alex K. Avatar answered Sep 22 '22 08:09

Alex K.