4

    Jan 19, 2011#16

    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.

      Jan 19, 2011#17

      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.]

        Mar 27, 2011#18

        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.

        8
        NewbieNewbie
        8

          Mar 27, 2011#19

          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.

          4

            Apr 15, 2011#20

            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.

            1
            NewbieNewbie
            1

              Mar 20, 2015#21

              It's been over four years since this post was last edited and I'm wondering if during that time there have been any advances to make execution of R script from within UltraEdit easier to get up and running?

              I recently installed Sublime Text and was able to get it to execute R using some very easy to follow guidance (<650 words) found here: Using R in Sublime Text 3

              Seems like UltraEdit would similarly have a recipe for writing script and sending it over to R 1 line at a time, blocks of lines, etc. Is the best solution simply to switch text editor venues?

              6,600548
              Grand MasterGrand Master
              6,600548

                Mar 21, 2015#22

                Well, it looks like there are several solutions to send a line, a block or an entire file to R from within UltraEdit.

                But nobody of those using R has put the entire solution together and wrote a simple step by step tutorial suitable also for UltraEdit beginners. I'm not using R and therefore can't do that. As an expert of UltraEdit I could setup the solutions provided here in about 15 minutes, but for UltraEdit beginners a better tutorial with clear step by step instructions would be definitely helpful. It should be of course no problem to pack
                1. an UltraEdit macro file containing the macro to use,
                2. the tool which is used to send the line, block or entire file to R,
                3. and a step by step tutorial in an HTML or PDF file explaining the steps necessary for configuring the user tool and configuring the macro for automatic load on startup of UltraEdit and how to use the macro/tool
                into a ZIP file and make it available for download somewhere.

                I'm quite sure that IDM Computer Solutions, Inc. would offer to upload the ZIP file on their server and publish the customer written tutorial as power tip or PDF file for download on the UltraEdit website. I know that IDM honors such a comprehensive work of a customer for the user community by offering a free license for one year. So if there is an UltraEdit user using currently an older version of UltraEdit reading this and using also R and wanting a license for newest version of UltraEdit (or any other IDM application) without paying money for it, contact IDM support by email and ask if IDM is interested on such a comprehensive power tip for UE with R interaction and if IDM would honor the work with a free license. I'm quite sure you get a positive reply on those 2 questions.
                Best regards from an UC/UE/UES for Windows user from Austria

                Read more posts (-8 remaining)