2014-03-03 38 views
1

我的問題是我想從ST2運行帶R 3.0.2的R腳本。更改由Sublime Text 2打開的R版本 - 在Windows中

當我安裝了ST2時,我使用增強R包對其進行了配置,以便能夠從ST2運行R腳本。完成的連接使用R 2.15.2。現在我想從ST2自動運行R 3.0.2。我沒有設法使它的工作原理是試圖修改偏好>包設置>增強R>設置默認Sublime Text 2 and R建議在設置用戶修改後的腳本:

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

和設置的默認腳本(我複製了除了我使用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": "/\\()\"‘-:,;[email protected]#$%^&*|+=[]{}`~?" 

有沒有人可以幫助我找到辦法呢? 感謝

+0

您是否已將'cmd'和路徑設置爲指向R3安裝? –

+0

你的意思是說,在控制面板中,我應該在「環境變量」中添加一個新路徑?或者你的意思是直接在ST2? – user3016665

+0

直接在ST2中。將其指向R-3可執行文件,而不是指向R-2可執行文件。 –

回答

0

打開Preferences -> Package Settings -> Enhanced R -> Settings-User並替換爲以下內容:

{ 
    "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": "/\\()\"‘-:,;[email protected]#$%^&*|+=[]{}`~?" 
} 

您需要確保路徑到Rgui.exeRscript.exe二進制文件是正確的。請注意,這是,如果你使用的是64位R.如果你是一個32位系統上,使用以下,而不是64位系統上:

{ 
    "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": "/\\()\"‘-:,;[email protected]#$%^&*|+=[]{}`~?" 
} 

保存文件,重新啓動爲卓異祝你好運,你應該全都定下來。

+0

路徑很好,但我得到了一個錯誤保存您的腳本「錯誤試圖解析設置:意想不到的字符,預計逗號或右括號在C:\ ... \ Enhanced-R.sublime-settings:8:9」。如果我按照建議改變了「:」的逗號,或者沒有任何改變,它也不起作用... – user3016665

+0

@ user3016665 - 我剛剛編輯了我的答案 - 有2個逗號缺失。請現在嘗試一下,讓我知道它是如何工作的。 – MattDMo