1

My problem is that I want to run R script with R 3.0.2 from ST2.

when I installed ST2 I configurated it using Enhanced R package to be able to run R script from ST2. The connection done is using R 2.15.2. Now I would like to automatically run R 3.0.2 from ST2. I did not managed to make it works by trying to modify preference>package settings> Enhanced R > setting default suggested in Sublime Text 2 and R is the modified script in settings user:

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

and the script for settings default (I copied the all but I working with Windows):

"osx" : {
    // R / R64 / Terminal / iTerm
    "App" : "R"
    // path to Rscript binary
    // "Rscript" : "/usr/bin/Rscript",
},

"windows" : {
    // R32 / R64
    "App" : "R64"

    // path to R binary
    // "R32" : "C:\\Program Files\\R\\R-3.0.2\\bin\\i386\\Rgui.exe",
    // "R64" : "C:\\Program Files\\R\\R-3.0.2\\bin\\x64\\Rgui.exe",

    // path to Rscript binary
    // "Rscript" : "C:\\Program Files\\R\\R-3.0.2\\bin\\x64\\Rscript.exe",
},

"linux": {
    // tmux / screen
    "App" : "tmux"

    // path
    // "tmux" : "tmux",
    // "screen" : "screen",

    // path to Rscript binary
    // "Rscript" : "",
},

// auto advance lines after sending command
"r_auto_advance": true,

// auto completions
"r_auto_completions": true,

// a list of packages which functions will show in the status bar
// "default_pkgs": ["base", "graphics", "grDevices", "methods", "stats", "utils"],

// a list of extensions
"extensions": ["r", "R", "s", "S", ".Rprofile"]

//  Allows for  '.' in R object names
// "word_separators": "/\\()\"‘-:,;~!@#$%^&*|+=[]{}`~?"

Does anyone could help me to find the way to do it? Thanks

Community
  • 1
  • 1
user3016665
  • 139
  • 2
  • 8
  • Did you set the `cmd` and path to point to your R3 installation? – Konrad Rudolph Mar 03 '14 at 17:10
  • do you mean that in control pannel I should add in "environment variables" a new path? or you mean directly in ST2? – user3016665 Mar 03 '14 at 18:09
  • Directly in ST2. Instead of pointing out to the R-2 executable, point it to the R-3 executable. – Konrad Rudolph Mar 03 '14 at 18:10
  • yes, I have done that. I tried to point out R3 both in Ehanced-R>setting default and user but it still open R version 2.15.2. I closed ST2 and re-open and restart my computer but did not work... – user3016665 Mar 03 '14 at 19:25
  • please [edit] your question and post the full text of your Enhanced R settings, both default and user (if they are different). By the way, if you want to change default values, it should **only** be done in the User settings - the Default file will get overwritten if/when the package gets upgraded, which can be quite often. – MattDMo Mar 03 '14 at 21:17
  • Also, are you just trying to run R scripts from Sublime, or do you want to set up [`SublimeREPL`](https://sublime.wbond.net/packages/SublimeREPL) for R, so you can have an interactive prompt? – MattDMo Mar 03 '14 at 21:20

1 Answers1

0

Open Preferences -> Package Settings -> Enhanced R -> Settings-User and replace its contents with the following:

{
    "windows" : {
        // R32 / R64
        "App" : "R64",

        // path to R binary
        // "R32" : "C:\\Program Files\\R\\R-3.0.2\\bin\\i386\\Rgui.exe",
        "R64" : "C:\\Program Files\\R\\R-3.0.2\\bin\\x64\\Rgui.exe",

        // path to Rscript binary
        "Rscript" : "C:\\Program Files\\R\\R-3.0.2\\bin\\x64\\Rscript.exe"
    },

    // auto advance lines after sending command
    "r_auto_advance": true,

    // auto completions
    "r_auto_completions": true,

    // a list of packages which functions will show in the status bar
    // "default_pkgs": ["base", "graphics", "grDevices", "methods", "stats", "utils"],

    // a list of extensions
    "extensions": ["r", "R", "s", "S", ".Rprofile"],

    //  Allows for  '.' in R object names
    "word_separators": "/\\()\"‘-:,;~!@#$%^&*|+=[]{}`~?"
}

You will need to ensure the paths to the Rgui.exe and Rscript.exe binaries are correct. Please note that this is if you are on a 64-bit system using 64-bit R. If you're on a 32-bit system, use the following instead:

{
    "windows" : {
        // R32 / R64
        "App" : "R32",

        // path to R binary
        "R32" : "C:\\Program Files\\R\\R-3.0.2\\bin\\i386\\Rgui.exe",
        // "R64" : "C:\\Program Files\\R\\R-3.0.2\\bin\\x64\\Rgui.exe",

        // path to Rscript binary
        "Rscript" : "C:\\Program Files\\R\\R-3.0.2\\bin\\i386\\Rscript.exe"
    },

    // auto advance lines after sending command
    "r_auto_advance": true,

    // auto completions
    "r_auto_completions": true,

    // a list of packages which functions will show in the status bar
    // "default_pkgs": ["base", "graphics", "grDevices", "methods", "stats", "utils"],

    // a list of extensions
    "extensions": ["r", "R", "s", "S", ".Rprofile"],

    //  Allows for  '.' in R object names
    "word_separators": "/\\()\"‘-:,;~!@#$%^&*|+=[]{}`~?"
}

Save the file, restart Sublime for good luck, and you should be all set.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • the path are fine but I got an error saving your script "Error trying to parse settings: unexpected character, expected a comma or closing bracket in C:\...\Enhanced-R.sublime-settings:8:9". If I change the ":" by comma as suggested or nothing it is not working either... – user3016665 Mar 05 '14 at 14:07
  • @user3016665 - I just edited my answer - there were 2 commas missing. Please try it now and let me know how it works. – MattDMo Mar 05 '14 at 15:08