EmEditor R code macro – Almost interactive R development for Emeditor

January 10, 2011

(This article was first published on DataDebrief, and kindly contributed to R-bloggers)

Get the new macro now hosted on github

Edit 18th Jan 2011: The below text refers to the old version of the macro and is no longer relevant, a new post will  describe the new macro, and it is also documented on the github site.

As a follow up to the earlier post regarding Emeditor Professional as an editor for R development, I have updated the script based on user feedback. The script now sends selected text or the whole (if no text selected) file to a running RGui Console if set to, otherwise as per previous iteration, will send it to rterm.

So, there are now 2 ways to run the macro, based on setting the value for a variable called “
useSource” – the default is “true“, which means any selected text (or file) will be sent to an already running instance of RGui; If useSource is set to “false“, the macro will operate the “old” way, by invoking rterm each time.

This has a number of benefits over invoking rterm each time:

  • Keeps the same workspace loaded – No need to keep repeating tasks, such as loading libraries, performing lengthy calculations etc, if you only changed some other part of the code;
  • Plots now display;
  • You can see what has executed.

The macro relies on the R command “source”, as sending text via sendkeys is unreliable. By default, the macro has echo=TRUE,keep.source=TRUE set. For further information on the source command, in R, run “help(source)“.

that when useSource=true, all R output is only shown in R, only errors with emeditor/macro will show in the Emeditor output window.

More features planned for the future:

  • Auto launch RGui if useSource=true but no rgui running;
  • Be closer in features to the vim r plugin; and
  • Move the macro code to github
  • Maybe create an actual emeditor plugin and run R in a hidden shell for more integration.

Get the new macro now hosted on github
As always, any issues please leave a comment, or log an issue

To leave a comment for the author, please follow the link and comment on their blog: DataDebrief.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)