Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Scripts

On GNU/Linux there are several options for a shell script to run Rattle. A simple script might be:



#!/bin/sh
wd=${PWD}
if [ ! -d ${HOME}/rattle ]; then mkdir ${HOME}/rattle; fi
echo "library(rattle); setwd(\"${wd}\"); rattle()" \
     > ${HOME}/rattle/.Rprofile
gnome-terminal --working-directory=${HOME}/rattle \
               --title="Rattle: R Console" \
               --hide-menubar --execute "R"

This uses a trick of creating a .Rprofile file in a specific location. Such a file is read when R is started up, and the commands there tell R to start Rattle. We can call this script rattle and place it in /usr/local/bin or in your own bin folder ${HOME}/bin.

Another possibility is to have a loop that waits for a sign that Rattle has terminated, buy placing the following into a file, perhaps called start_rattle.R:

library(rattle)
rattle()
while (!is.null(rattleGUI)) Sys.sleep(5)

and then run this from the command line:

$ R --no-save < start_rattle.R

This relies on the fact that rattle() actually dispatches and returns control back to the console. Without the while loop the script (and thus Rattle) terminate as soon as it starts. The sleep/loop waits for the "rattleGUI" variable to be set to NULL (which Rattle does on quitting) and then terminates. This is not so useful since it locks the console, although for some purposes it might be desirable. Up to 5 seconds of delay on exit could also be annoying.

Copyright © Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
The PDF version is a formatted comprehensive draft book (with over 800 pages).
Brought to you by Togaware. This page generated: Sunday, 22 August 2010