Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

R Dataset

Rattle can use a dataset that is already loaded into R (although it will take a copy of it, with memory implications). Only data frames are currently supported, and Rattle will list for you the names of all of the available data frames. We can load data frames into R in a number of ways, and this is the approach to take when using one of R's many data reading functions. For example, we can read SPSS datasets using the read.spss. The resulting data frame can then be loaded into Rattle using this R Dataset option.

The data frames need to be constructed in the same R session that is running Rattle (i.e., the same R Console in which you lo the Rattle package). This provides much more flexibility in loading data into Rattle, than is provided directly through the actual Rattle interface.

This is useful if you have data in a spreadsheet (or any application really) and want to directly paste that data from a clipboard into R. Figure [*] illustrates a spreadsheet with three columns of data selected and copied to the clipboard (by the right mouse button menu selecting the Copy option). This data can then be loaded into R quite easily as illustrated in Listing [*]. There, we also convert the date from a string, which is nothing more than a string, into a actual date data type.



[float,caption={Load data from clipboard into R{}},label={lst:clipboard.into.r}]
> expenses <- read.table(file("clipboard"), header=TRUE)
> expenses$Date <- as.Date(expenses$Date, format="%d-%b-%Y")
> expenses
         Date Expense   Total
1  2005-11-17   19.50   19.50
2  2005-11-23  -15.00    4.50
3  2005-12-10   30.00   34.50
4  2006-01-23 -110.00  -75.50
5  2006-01-28  -20.00  -95.50
6  2006-02-14  -10.00 -105.50
7  2006-02-14  300.00  194.50
8  2006-02-26  220.41  414.91
9  2006-03-03  -20.00  394.91
10 2006-07-14   50.00  444.91
11 2006-07-17   -5.00  439.91
12 2006-09-08 -120.00  319.91
13 2006-09-08 -130.00  189.91
14 2006-10-22   55.00  244.91
15 2006-11-23  135.00  379.91
16 2007-02-11  -90.00  289.91
17 2007-02-22  -20.00  269.91

We can then load this into Rattle directly, as in Figure [*].

As another example, you may want to load data from an SQLite database directly, and have this available in Rattle.

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