Integrate R with UEStudio / UltraEdit

This forum is user-to-user based and not regularly monitored by IDM.
Please see the note at the top of this page on how to contact IDM.

Re: Integrate R with UEStudio / UltraEdit

Postby johndjohnson » Tue Jan 18, 2011 11:46 pm

Ok, I have tried to move this a step forward. I have created a small tool similar to the tool mentioned above with SPSS. It's a small command line that will shovel commands to and from R using the socket server.

Executable is located at
http://dl.dropbox.com/u/10592797/send.zip

The git repository with README is located at
https://github.com/randomjohn/Ultraedit-to-R
(If you get the executable above you do not have to download the source or compile it.)

There are a lot of rough edges, as I am only a hobbyist at best when it comes to C programming (and especially this type of programming -- I basically ripped off the winsock tutorial at MSDN), but hopefully this represents a step forward in this issue. It is also not for the faint at heart - to get the best use out of this you need to understand custom tools, macros, and scripting. As for setting up things on the R end, it is really not that hard. You will need the svSocket package, which is easily installed. Then you issue the commands
library(svSocket)
startSocketServer()
in R, and then you can minimize the program. Then you set up a tool as described in the readme (visit the github site for the README, please!) and then can create macros and scripts to call the tool as needed. Things will not echo on the R end as you would expect coming from Tinn-R, but maybe someone enterprising can write a function to do that in R.
johndjohnson
Newbie
 
Posts: 4
Joined: Tue Jan 18, 2011 11:34 pm

Re: Integrate R with UEStudio / UltraEdit

Postby johndjohnson » Wed Jan 19, 2011 10:02 am

And of course I'm already finding bugs, or, rather, what I suspect is some lack of sophistication in the programming. Looks like I need to put in some options to wait for a response, as things that do not return immediate response do not get their results shown.

Long story short, this is bleeding edge. Use at your own risk.

[Update: I fixed the tool to fix the bugs and add a configurable delay.]
johndjohnson
Newbie
 
Posts: 4
Joined: Tue Jan 18, 2011 11:34 pm

Re: Integrate R with UEStudio / UltraEdit

Postby johndjohnson » Sun Mar 27, 2011 6:01 am

I have found what I think is a superior solution, though it shows the output in R rather than Ultraedit.

First, navigate to http://www.pspad.com/en/pspad-extensions.php. (Yes, a "rival" text editor :D ). Grab the "accessR.zip" file. All you need from the zip archive is a program called clipboardtor.exe, which was written using a utility called autoit (http://www.autoitscript.com/site/autoit/. You can read more about AutoIt at the link provided, but in a nutshell the utility allows you to script GUIs, and, furthermore, compile the script into an application. ClipboardtoR is therefore a standalone application that essentially finds the R console and pastes into the window. (It also works with an R session through PuTTY, if you need that.) The only drawback is that it is supposed to start R if it isn't already, but I'm guessing recent changes have broken that functionality.

The concept for using it to work with Ultraedit is the same as my utility above. Put ClipboardtoR in a suitable location, and create a tool to call it as a DOS program. You can then write macros and scripts to select text (such as a line), copy text, and call the tool which will send it to R. There is one caveat, though. I prefer using macros in this case over scripts because scripts will create a new, temporary window indicating execution. ClipboardtoR will take this temporary window as the "active" window and attempt to return focus to it after R does its thing. Of course, it will fail and leave R with the focus. Using macros solves this problem.
johndjohnson
Newbie
 
Posts: 4
Joined: Tue Jan 18, 2011 11:34 pm

Re: Integrate R with UEStudio / UltraEdit

Postby marlow » Sun Mar 27, 2011 2:08 pm

Thanks @johndjohnson that sounds like an interesting find. Have to investigate. I've occasionally been tempted to try one of the auto-- systems, but have always been stymied by the existential dilemma of "autohotkey or autoit?" :D

Meanwhile, what I've done more recently is switch to routinely using the new open source ide: Rstudio. http://www.rstudio.org The initial version was released recently and even tho it is v 0.9x or whatever, it is absolutely great. I installed it the day it was announced, said "my that looks nice" and went back to work as usual with UE & Tinn-R. --but within about 2 days I found I'd switched to using UE&rstudio period!! I do my main editing in UE and then keep one or more modules open as I need them in rstudio--they interact fine together.

I use rstudio & UE on my main win system & rstudio on my mac laptop. I haven't yet adopted UE for osx & the editor in rstudio is okay for the limited editing I do on the laptop. Inasmuch as the mac rgui differs from the win rgui--it is a great benefit to me that rstudio itself looks & behaves pretty much identically on both systems (some minor differences in editing rprofile.site, but that's expected). The rstudio editor is much more modest than UE & system will presumably continue to improve.

The UE&rstudio combo doesn't solve this thread's original problem of not being able to send code from UE to r, but the other benefits of rstudio's ide--for me--tilt the balance in favor using this combo. I'm very happy using them.
User avatar
marlow
Newbie
 
Posts: 8
Joined: Thu Nov 17, 2005 12:00 am

Re: Integrate R with UEStudio / UltraEdit

Postby johndjohnson » Fri Apr 15, 2011 12:23 pm

Thanks for the kind words.

Not to flog a dead horse, but I've found yet a third solution to this issue over at http://batchfiles.googlecode.com/. I haven't tested it out yet, but there appears to be some very useful files for integrating Ultraedit (or other text editors) with R. Ones I found of immediate interest are clip2r.js and some of the .bat files that retrieve the directory of the latest R from the Windows registry. At first glance, the advantage of these is that they take advantage of elements already in Windows rather than requiring the installation of a helper app.
johndjohnson
Newbie
 
Posts: 4
Joined: Tue Jan 18, 2011 11:34 pm

Previous

Return to UEStudio General Discussion