WriteData: write *.data files

Description Usage Arguments Details Author(s) References See Also Examples

Description

Writes Data, DataDefined, Key and Names in the *.data file format. WriteData is the function for writing *.data files.

The *.data file format enables the user to import data to Microsoft Excel, Mathworks Matlab and allows to inspect and edit data within every text editor. *.data file format is a tab separated csv file with specific header. To prevent failures each column is saved with a CRC-32 checksum. Every *.data file contains a DataDefined line which describes the data in each column. The key column is a unique column of integer values. One value codes exactly one data record, where this single line of data equals one observation. Numbers are stored under Data inside the file strings, using DataDefined = 9,0,1. Strings are saved as Names using DataDefined = 6. DataDefined 2,3 and 8 are used for internal purposes.

Usage

1
2
WriteData(FileName, Data, OutDirectory = getwd(), 
			Header =c(), DataDefined, Key, Comment, Names)

Arguments

FileName

string, name of file where the data will be stored

Data

[n,k] matrix or a data.frame containing the data

OutDirectory

optional, string, name of directory the data will be saved in, default getwd()

Header

optional, string vector with the names for the key and data columns, by default 'Key' for DataDefined==9, 'Cls' for DataDefined==3, 'C1', 'C2', 'C3', 'C4' etc. for DataDefined==1 or ==2, must not contain whitespace

DataDefined

optional,vector of column type: keys (0=ignore, 1=data(numeric), 2(numeric), 3=class(numeric), 6=Names(character), 8=class(character), 9=key), default is only 1's or 6's with leading 9 for the key column

Key

optional, a numeric vector with unique number for each line, by default 1:n, n being the number of rows

Comment

optional, array of characters to be written in the first line of the file, it will be marked with '%'

Names

optional, list or string matrix with text for each line to be put as last column, usually a short identifier

Details

composition of the *.data file:

all comment lines start with '%', all header lines with '#'

After none or one comment line the header starts with the following information:

1.line: number of rows in Key respective data

2.line: number of columns in file, including Key column

3.line: checksums for each column

4.line: names of columns defined by input variable Names, if not defined see below

After this the key column and the data follows, each column separated by a white space, each row separated by new line.

The length of Key has to be ncol(Data) or ncol(Data[[1]]) respectively. If Key is empty it is replaced by a vector 1:ncol(Data) NOTE: there can be only ONE column with dataDefined == 9 i.e. the column containing the Key

If Names is empty, it is replaced by default names: The default name for a DataDefined==9 column is 'Key'. The default name for a DataDefined==3 column is 'Cls'. The default name for DataDefined==1 or ==2 is 'C1', 'C2', 'C3', 'C4' etc. DataDefined may only contain numbers 0,1,2,3,6,8 and 9. Please use DataDefined == 6 only once. If DataDefined is empty or wrong it is replaced by c(9,1,..).

Author(s)

Tim Schneider, Michael Thrun

References

www.uni-marburg.de/fb12/datenbionik mthrun@mathematik.uni-marburg.de

See Also

ReadData

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#create a matrix
#mat = matrix( 
	#c(1,0,0,0,1,0,0,0,1), 
	#nrow=3, 
	#ncol=3) 
	
#Write this matrix into the current directory
#WriteData(FileName = "test.data",Data = mat)
	
#Write this matrix into a different directory, for example under MacOS X
#WriteData(FileName = "test.data",Data = mat, InDirectory = '~/Desktop/')

aultsch/DataIO documentation built on May 14, 2019, 10:34 p.m.