Recently I've made the switch from Windows Vista to Ubuntu Linux. After switching, the first thing I needed was an editor for R package. R is my favourite and most-used environment for statistical computing. It is free and simple yet a very powerful tool for simple to high profile statistical computing.
I have done a small research on this and found several candidate software. Emacs and ESS (Emacs Speaks Statistics) turned up with maximum hits when I searched in Google. Most frequent R-users rely upon Emacs and ESS (Emacs Speaks Statistics) for obvious reasons. I will review Emacs and ESS in a separate post. In this post, I will limit discussing about using gedit and Rgedit as a frontend for R statistical package.
gedit is the default text editor in Gnome environment in Linux. And gedit has a simple but very useful plugin called Rgedit that makes it an excellent IDE for R. Of the many features of Rgedit, here I list only a few.
- It splits the window into two panes, and runs R in the bottom panel (can be set as visible or hidden using the Ctrl+F9 key. Default is hidden. This pane is detachable too :) )
- Out of the box syntax highlighting with or without the .R extension
- Single line code-processing or processing in blocks or the entire file
- Multiple R workspace can be run simultaneously (Shortcut: Shift+Ctrl+S)
- Customisable shortcut keys
Installation of Rgedit
Download and extract from http://sourceforge.net/projects/rgedit/
The detailed instructions are available in the Readme.txt file. I am copying from it:
To install, extract the RgeditXX.tar.bz2 archive somewhere and copy the contents of the resulting folder into to your ~/.gnome2/gedit/plugins folder (please note the "." dot; create this folder if necessary). Now, your ~/.gnome2/gedit/plugins folder should also contain:
RCtrl <- this is a folder
ReadMe.txt <- this ReadMe.txt file
Then activate the "R integration" plug-in from gedit (Go to Edit > Preferences > Plugins, and activate the 'R Integration' plugin)
If you are searching for "syntax highlighting for R" then find no more. Its there in gedit. All you need is to enable the options when you use gedit.
One of the nice features of RGedit/gedit is that you can define your keyboard shortcuts yourself. Its built in shortcuts are also very intuitive. Some of them are listed below:
To define custom shortcuts, open gedit and from the menu, go to R > Configure R Interface > Edit Keyboard Shortcuts. I've defined two new shortcuts, (i) Shift+Alt+S to open a new R session, (ii) Shift+Alt+Q to close an R session. See the keyboard shortcut configuration screenshot below.
Example of shortcut keys with Rgedit
- Start gedit either from the terminal or from Applications > Accessories > gedit Text Editor
- Start an R session : Shift+Crtl+S
- Make the R workspace visible at the bottom of the gedit panel: Ctrl+F9
- Enter a code on the upper panel and press Shift+Ctrl+R to run that line
- To run several lines of code together, select lines and press Shift+Ctrl+E
Some must-have plugins for gedit
The default gedit comes with a few plugins. If you are using gedit for editing/writing and managing R codes, then you need the following plugins.
- Code Comment: To insert and remove comments in your R code [Shortcuts: Crtl+M to comment and Shift+Ctrl+M to remove comment]
- Bracket Completion: To automatically complete ending bracket.
How to get these extra plugins?
If you are using Ubuntu Linux, go to a Terminal and type the following at the prompt:
sudo apt-get install gedit-plugins
After installing, open gedit, and enable the plugins from
Edit > Preferences > Plugins