Launch R document from Smultron / Fraise

July 12, 2010
By

(This article was first published on Timothée Poisot » R, and kindly contributed to R-bloggers)

Perhaps you know of the defunct Smultron, a lightweight editor for Mac OS X. There exists a new version called Fraise, with the same features. Among them, R syntax highlighting and the possibility to interact with the R Gui console.

To do so, when in Fraise, just push Cmd-B to open the Commands window, then create a new command, and type

#!/bin/bash
osascript -e ‘tell application "R.app" to activate’
osascript -e "tell application \"R.app\" to cmd \"setwd(‘%%d’)\""
osascript -e "tell application \"R.app\" to cmd \"source(file=’%%p’,
print.eval=TRUE)\""

You can assign a keyboard shortcut to this command. Whenever you will hit the keys, R.app will activate, set the good working directory, and execute your code. Now, you see that it is straightforward to modify this code / create another so that you execute the selected text only.

While Fraise is less powerful than TextMate and its R plugin, it is free, and really easier to instal that SciViews or StatEt.

To leave a comment for the author, please follow the link and comment on his blog: Timothée Poisot » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: 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...

Tags: , , ,

Comments are closed.