Dataset Input and Output

© A.I. McLeod, February 2002

Dataset Structure

Our Mathematica functions in the package mviz, work with a dataset matrix, X, which has n rows and p columns.  A typical dataset file includes at beginning comments prefixed by #.  For example, the first few lines of the file envir.dat look like:

#Measurements on 111 successive days of daily 
#ozone concentration (ppb), 
#wind speed (mph), 
#daily maximum temperature (degrees F), 
#and solar radiation (langleys) 
#on 111 days from May to September 1973 in New York. 
#Source: StatLib
#Columns: ozone, radiation, temperature, and wind. 
#
#O	R	Tp	W
41	190	67	7.4
36	118	72	8
12	149	74	12.6
18	313	62	11.5
........................................

Dataset Input

In the mviz package, we provide the function ReadData for data input.

<< "d:\\math\\2001\\mviz.m"

?ReadData

Example

x = 
        Partition[ReadData["d:\\math\\2001\\mviz\\data\\envir.dat"], 
          4];

Dimensions[x]

x = 
        Partition[
          ReadData["d:\\math\\2001\\mviz\\data\\envir.dat",  
            Silent -> True], 4];

Data Output

For data output, the function WriteData may be used.  Only a single column is provided on the output. If the input is a matrix, the output is by row.

?WriteData

Example

WriteData["c:\\eg2.dat",  x,  
        Title -> "Environmental data\n 111 observations on 4 variables\n \
ozone, wind speed, temp and radiation"];

!! eg2.dat

#Environmental data
# 111 observations on 4 variables
# ozone, wind speed, temp and radiation
41.
 190.
 67.
 7.4
 36.
 118.  etc.