Open gregforcey opened 11 years ago
Sorry I don't have access to a windows machine so I can't test this myself. One possible solution is that R might not be in your PATH
(see fi you are able to run R from the cmd window without being in the application's directory). Otherwise I'll just leave this thread open and see if some other windows user can chime in and help out (I know they are out there).
Thanks for responding.
R wasn't in my path, but it is now. Unfortunately that doesn't fix the problem.
This is what I have tried so far.
1) Added C:\Program Files\R\R-2.15.2\bin\x64 to my path
2) Changed R64 to R.exe in the Rtools.py file. Should this be Rgui.exe instead?
3) I noticed there was another file as part of the package called R.sublime-build that references R64. Should that also be changed to R.exe or Rgui.exe? I tried changing it and it still didn't work so I don't know if that should be changed or not.
4) I noticed that there was a keymap file for OSX but not for windows. So I copied the text from the OS X keymap file and pasted it into my Key Bindings- User file. I changed the keybindings to F8 and shift-F8 which is similar to Notepad++ which is what I'm used to.
Still nothing has worked and I'm out of ideas. Has anyone been able to get this to work on Windows?
Yes, please try changing R.exe to Rgui.exe in Rtools.py. Leave the sublime-build as it is.
The key bindings should map to Windows as well. The super
key shortcut is command on osx and just the windows key on a standard windows keyboard. Just copy those in your keybindings > User and see if that helps. If that doesn't solve your issues, I'd suggest posting a question to the Sublime forum. You should be able to get some useful responses from a windows user (Sorry I don't have access to one, not even a VM).
I was able to Rtools to work in windows. To do so I edited my R.sublime-build file, I replaced the line "cmd": ["osascript", "-e", "tell app \"R64\" to cmd \"source('$file')\"\n"] with "cmd": ["Rscript", "$file"]
Since osascript is a Mac only tool I had to use the application provided with R called Rscript. This is designed to be passed an R file run it and return the results. I am running windows 7, R 2.15.2, and ST2 version 2.0.1 build 2217
I since I do not have access to a Mac I do not know how Rtools behaves when being ran by osascript. However I would imagine that if you are able to get the same behavior with Rscript (assuming that it is available for Mac) you would then be able to make your package platform independent. Assuming you could have the R path set by a variable that is defined by the user that it ;) Hope that helps!
Thanks GildedRabbit for the suggested. I did what you said, and I now I see the Rscript briefly flash when I pass commands to R. I still can't seem to get them to pass to the Rgui.
In addition to what you suggested I had to update the Rtools.py file with the following, changing the args to Rscript and R64 to Rgui.exe.
selection = self.cleanString(selection).split("\n")
# define osascript arguments
args = ['Rscript']
# add code lines to list of arguments
for part in selection:
args.extend(['-e', 'tell app "Rgui.exe" to cmd "' + part + '"\n'])
# execute code
subprocess.Popen(args)
I also copied the keybindings from the R into the Key Bindings - User file and edited it to my needs: [ { "keys": ["ctrl+enter"], "command": "send_selection" }, { "keys": ["ctrl+shift+alt+r"], "command": "r_docs", "context": [ { "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }, { "operand": "source.r", "operator": "equal", "match_all": true, "key": "selector" } ] } ]
Were you able to get Rtools to pass the commands to Rgui? If not, is there a way to make the Rscript window stay open rather than closing immediately after running your commands? Thanks for the help so far.
G-Force glad that kinda worked for you, and thanks for the key bindings.
I have not been able to get Rtools to pass to the Rgui. I think this is because Rgui does not accept the '-file' option like the commend line R does. I am new to Sublime Text and Java is not my strong point, however I did grab the source for NppToR and go over it. It looks like in order to pass to the Rgui and have it remain open the text desired to be passed needs to be stored either in a variable or the clipboard, then pasted into an existing Rgui session.
I have not yet gone over the code but I imagine that looking at SublimeREPL may offer some clues. As it can offer the functionality you are referring to, granted with some bugs..... Don't know if you saw this yet but here is the article I came across (you are actually mentioned in it). http://tomschenkjr.net/using-sublime-text-2-for-r/ I do not use SublimeREPL as I have been trying to get Rtools to work in windows, and feel with a dedicated R plugin Sublime could be the best editor for the R language.
hope that helps, If I figure out anything more I will post it here.
Are there step by step instructions for how to get this to work on windows? I tried changing the R64 to R.exe in the Rtools.py file but it still didn't work. I also changed the key bindings to something more windows friendly, but it still didn't work. Any suggestions?