You are here

Using gedit or Rgedit with R

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.

  1. 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 :) )
  2. Out of the box syntax highlighting with or without the .R extension
  3. Single line code-processing or processing in blocks or the entire file
  4. Multiple R workspace can be run simultaneously (Shortcut: Shift+Ctrl+S)
  5. 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
RCtrl.gedit-plugin
RCtrl.preferences
RCtrl.py
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)

Syntax Highlighting

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.

RGedit syntax highlighting in R

Shortcut Keys

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.

Keyboard shotcut keys for Rgedit

Example of shortcut keys with Rgedit

  1. Start gedit either from the terminal or from Applications > Accessories > gedit Text Editor
  2. Start an R session : Shift+Crtl+S
  3. Make the R workspace visible at the bottom of the gedit panel: Ctrl+F9
  4. Enter a code on the upper panel and press Shift+Ctrl+R to run that line
  5. 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.

  1. Code Comment: To insert and remove comments in your R code [Shortcuts: Crtl+M to comment and Shift+Ctrl+M to remove comment]
  2. 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

Comments

Hey man!

Nice posting. I am using RGedit, and just added code comment / bracket completion! Thanks a lot.

Do you know if it is possible to add a function recognition (highlighting ) functionality on GEdit?

thanks!

drp

Thanks a lot for this editor. I have problem with it. 'R Integration' plugin does not appear in plogins even after sudo apt-get install gedit-plugins. I am ubuntu user. I understood that in the unzip folder RCtrl.preferences is missing after several time trying to download the package. I wonder you are able to help me with this problem. Thanks. Gagea

Thanks for the useful post. I also cannot find the file "RCtrl.preferences" and therefore "R Integration" plugin does not appear. I have tried downloading several times. Any advice?

In ubuntu11.10, gedit is gedit 3, so you have to copy the content in ~/.local/share/gedit/plugins, rather than in ~/.gnome2/gedit/plugins.
--Guangting

Hi all, I am working with linux and Rgedit, and I love it, but since I am not really very good with the linux environment... I want to know how do I upgrade my R version... the automatic upgrade window does not do it ... and I now need to install a package that only works with an upgraded version in R.... Any help suggestion will be extremely appreciated...Thanks!

Hi Ruth,

Are you comfortable with the instructions in this document? http://cran.r-project.org/bin/linux/ubuntu/README

You need to spend some time to read it. Its not difficult at all.

I am currently pretty busy preparing for my dissertation defense, and as such, unable to spend much time right now. In a three days time, if you need more help, I will be happy to offer.

Thanks for your reply. I will read this... I know I should spend sometime to explore more linux!!!
Anyways thanks for your prompt reply and good luck and congratulations on your dissertation... Best wishes,
Ruth

Ubuntu 10.04. I followed all the instruccion but "R Integration" plugin does not appear inside gedit -> edit > preferences -> plugins. I have tried downloading several times without exit. Any advice?

I've just started using Rgedit, but I can't seem to find out how to display the left panel, nor to enable code folding...

Thx for any help

I am using Ubuntu 12.04 (Precise), Gedit-3.4.1, R-2.15.2, rgedit v0.8.0.1-Gtk3

latest release of rgedit v0.8.0.1-Gtk3(16 January 2013),don't have below files
RCtrl.gedit-plugin
RCtrl.preferences
but it have RCtrl.plugin file instead of RCtrl.gedit-plugin.

I extract content of rgedit v0.8.0.1-Gtk3 to /usr/lib/gedit/plugins/
& enable "R integration" plugin from edit>preferences>plugin
in main menu "R" is appeared,
but when I click on "configure R interface",doesn't show configuration panel.
even I click on other option,no activity is showing ?

Should I rename RCtrl.plugin file to RCtrl.gedit-plugin & use it ?
& which version should I use ? rgedit v0.8.0.1-Gtk3 or rgedit v0.8.0.1-Gtk2

What will be the problem ?

Add new comment