---
author: einar
comments: true
date: 2009-02-07 18:55:53+00:00
layout: post
slug: science-and-kde-rkward
title: 'Science and KDE: rkward '
wordpress_id: 533
categories:
- KDE
- Linux
- Science
tags:
- KDE
- Linux
- R
- rkward
- Science
---

I try to use FOSS extensively for my scientific work. In fact, when possible, I use _only_ FOSS tools. Among these there is the R programming language. It's a Free implementation of the S-plus language, and it's mainly aimed at statistics and mathematics. As the people who read my scientific posts know, I don't like R much. But sometimes it's the only alternative.

Well, what does R have to do with KDE? With this post I'd like to start a series (hopefully) of articles that deals with KDE programs used for scientific purposes. In this particular entry, I'll focus on rkward, a GUI front-end for R.
<!-- more -->
**Introduction**

Although R is a programming language, it's mainly used in an interactive session, started from the terminal. The standard installation can be improved by the use of add-on packages, _libraries_ in R-speak, which can be installed from the Internet (Comprehensive R Archive Network or CRAN) or from local files. One of the most famous third party repositories is the Bioconductor project, which hosts a lot of packages used by life scientists who do bioinformatics.

The Windows version of R has a GUI (Rgui) which provides extra functionality, such as package management and loading, and other goodies. Although there were plan for a GTK+ frontend for Linux, the project is (as far as I know) stuck in a limbo.

That's where rkward comes to the rescue. It's a GUI front-end for R for KDE4, which aims to provide a graphical shell for many R commands and environments (and especially the publication-quality plotting figures).

**Getting rkward**

rkward is available from [Sourceforge.net](http://rkward.sourceforge.net/). Unfortunately, if you use a recent (>=2.8) version of R  it won't compile, due to the changes in R itself. For that, you need to directly download the sources off SVN with a command like this

{% highlight cpp %}

svn co https://rkward.svn.sourceforge.net/viewvc/rkward/trunk/rkward/

{% endhighlight %}

Either way, the sources are compiled the usual, way, that is

{% highlight cpp %}

cd rkward-xxx # Your rkward source dir
mkdir build; cd build
cmake  -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ../
make
{% endhighlight %}

Followed by `make install` as root or using sudo, depending on your distribution.

**rkward at a glance**

**[singlepic id=263 w=320 h=240 float=center]**

This is how rkward looks when loading it up (yes, it's in Italian because that is my own locale). You have the R console (which I brought up) and then an output window which is used to display results. There is also another tab called "mio.dataset" (my.dataset) which keeps data, in a spreadsheet-like form. This is useful when you want to create your own datasets from scratch, or if you want to inspect one you have loaded.

So how do you start coding? You can create a new script using the "Script File" button. Like that, you can input R commands and then execute them all at once, or the current line. If you prefer interactive work, you can use the R command line (shown in the screenshot).

[singlepic id=264 w=320 h=240 float=center]

You can also use rkward to import data: R provides a series of functions (like `read.table`) to load data sets (usually comma- or tab-delimited text files). rkward provides a complete GUI to those functions, which is shown in the screenshot above. Notice that for working, it requires PHP (the line command version).

[singlepic id=266 w=320 h=240 float=center]

Ok, we have data loaded. Now we may want to do some operations: rkward provides front-ends to many of R's statistical functions. In the screenshot, we can see the GUI for a two-variable t-test. Notice how it shows also the code, so the most experienced R people can view exactly what it does.

Like with statistics, R has powerful support for graphics, and even in this case rkward offers some frontends, for example histograms, boxplots, and scatter plots. You can also plot all kinds of distributions.

[singlepic id=265 w=320 h=240 float=center]

Lastly, rkward can manage your R packages (R package management is akin to one of a Linux distribution), and als your package sources. You can install or upgrade packages, and select where they'll get installed to.

**Conclusions**

rkward is a nice frontend for the R programming language, which adds a GUI with the power of KDE to R. Unfortunately the program is still somewhat unstable (also shown by a warning when you run it) and its main developer has currently very little time to work on it. In case you may want to help, you can hop to the r[kward-devel mailing list.](http://sourceforge.net/mailarchive/forum.php?forum_name=rkward-devel)
