2

I would like to run R files in Sublime Text 3 using SublimeREPL. In Preferences -> Browse packages... in the file SublimeREPL\config\R\Main.sublime-menu, I added the R path ("id" -> "repl_r" -> "cmd" -> "windows")

[
     {
        "id": "tools",
        "children":
        [{
            "caption": "SublimeREPL",
            "mnemonic": "R",
            "id": "SublimeREPL",
            "children":
            [
                {"command": "repl_open",
                 "caption": "R",
                 "id": "repl_r",
                 "mnemonic": "R",
                 "args": {
                    "type": "subprocess",
                    "external_id": "r",
                    "additional_scopes": ["tex.latex.knitr"],
                    "encoding": {
                        "windows": "$win_cmd_encoding",
                        "linux": "utf8",
                        "osx": "utf8"
                        },
                    "soft_quit": "\nquit(save=\"no\")\n",
                    "cmd": {"linux": ["R", "--interactive", "--no-readline"],
                            "osx": ["R", "--interactive", "--no-readline"],
                            "windows": ["C:/Program Files/R/R-3.2.3/bin/x64/Rgui.exe", "--ess","--encoding=$win_cmd_encoding"]},
                    "cwd": "$file_path",
                    "extend_env": {"osx": {"PATH": "{PATH}:/usr/local/bin"},
                                   "linux": {"PATH": "{PATH}:/usr/local/bin"},
                                   "windows": {}},
                    "cmd_postfix": "\n",
                    "suppress_echo": {"osx": true,
                                      "linux": true,
                                      "windows": false},
                    "syntax": "Packages/R/R Console.tmLanguage"
                    }
                }
            ]
        }]
    }
]

then in tools - > build system - > new build system I add it to the file:

{
    "target": "run_existing_window_command",
    "id": "repl_r",
    "file": "config/R/Main.sublime-menu"
}

When I run a file.R, the R program launches and nothing happens.

I have already made these manipulations for python and when I launch a file.py a new tab sublime text opens (called : REPL [ python ] ) . I want the same thing when I run a file.R.

(sorry for my bad English)


I made the changes but when I run the script, the window "REPL*[r]" opens with the text: R Version 3.2.3 ( 2015-12-10 ) ..., but the commands written in the script does not set off

test.R

print(1+1)

i do tool -> builds and nothing is displayed


I put :

"windows": "windows": ["C:/Program Files/R/R-3.2.3/bin/x64/R.exe","-f","--ess","--encoding=$win_cmd_encoding"]},

I get a error : Fatal error : Can not open file '--ess' : No such file or directory

And with

    "windows": "windows": ["C:/Program Files/R/R-3.2.3/bin/x64/Rscript.exe","--ess","--encoding=$win_cmd_encoding"]},

I get a error too :

file name is missing
***Repl Closed*** 
MattDMo
  • 100,794
  • 21
  • 241
  • 231

2 Answers2

2

You are attempting to run the R GUI (graphical user interface). SublimeREPL expects the command-line version of R, which under Windows is called Rterm.exe. Simply change that parameter, and you should get a new tab in Sublime called REPL [r]. You can also just call R.exe. The section should look like this:

"windows": [
    "C:/Program Files/R/R-3.2.3/bin/x64/R.exe",
    "--ess",
    "--encoding=$win_cmd_encoding"
]

One other change you may want to make - if you're using the R-Box package (and I highly recommend it), change the "syntax" line to

"syntax": "Packages/R-Box/syntax/R Extended.sublime-syntax"

I'd suggest reading up on SublimeREPL a bit. The config menu you're trying to customize is to open an R REPL within Sublime. Once it's open, you can then use the commands under Tools -> SublimeREPL to send entire files or fragments of files to the running REPL for evaluation.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
-1

What @MattDMo wrote is true in general, but wrong in particular. Rterm.exe, Rcmd.exe are all leftovers from old times (R v2?). On relatively modern R installation the way to run scripts is Rscript.exe, or R.exe -f. Please check R.exe, Rcmd.exe, Rscript.exe and Rterm.exe: what's the difference? for further information

UPDATE

You might to take a look at Running R Code from Command Line (Windows) as well

Community
  • 1
  • 1
Severin Pappadeux
  • 18,636
  • 3
  • 38
  • 64
  • 1
    Does `Rterm.exe` still work the same as `Rscript.exe` or `R.exe -f`? – MattDMo Mar 04 '16 at 15:47
  • 1
    Unfortunately, this is incorrect. Did you actually test it before answering? Firstly, using `Rterm` *does* give the correct behavior. Second, `Rscript` is for running scripts, not for opening a REPL, which is what we're trying to do here. `R -f` expects a file name, which is not specified. – MattDMo Mar 04 '16 at 19:10