Next: redo() Up: MacAnova Help File Previous: readcols()   Contents

readdata()

Usage:
readdata(filename,name1,...,namek [,factors:F  or sort:F]
  [,keyword phrases]), filename a CHARACTER scalar, name1,... names,
  quoted or unquoted variable names
readdata(filename,vector("name1",...,"namek") [,factors:F or sort:F]
  [,keyword phrases])
readdata(filename [,factors:F or sort:F] [,keyword phrases])



Keywords: input, files
readdata(FileName,name1,name2,...,namek) uses vecread() to read
one or more columns of data from file FileName, creating variables.
name1, name2, ..., namek.  The variable names can be either quoted
("weight") or unquoted (weight) but must be legal MacAnova names.

When the value of a variable in the first line of the data is not a
number, the values for that variable are read as CHARACTER data and then
turned into a factor, with factor levels maintaining the alphabetical
order of the CHARACTER values.

readdata(FileName,name1,...,sort:F) does the same except if any factors
are created, the factor levels are assigned in the order CHARACTER
values are encountered.

readdata(FileName,name1,...,factors:F) does the same except a column
starting with a non-numerical word is not translated into a factor but
is read as a CHARACTER vector.

readdata(FileName [,factors:F or sort:F]) does the same except the names
for the variables are expected to be in the first line of the file.

For all usages, the number of variable names, whether given as arguments
or taken from the first line of the file, must divide the total number
of data values.

A line giving the name and type (REAL, factor or CHARACTER) is printed
for each variable read.  If the variable is REAL and has MISSING values,
the number of MISSING values is also printed.  Argument 'quiet:T'
suppresses this output.

Any line in the file starting with skip character '#' is automatically
skipped and is echoed to output by default.

readdata() is intended as a replacement for readcols().  It can handle
files in which some data columns are non-numerical and can get variable
names from the first line of the file.

The file should consist of k columns of "words" separated by spaces,
commas or tabs.  A word is any set of consecutive characters not
including a comma, space or tab.

A column whose first word is a number or MISSING ('?', '.', '*' or 'NA')
is read as a REAL vector.  Any word in the column after the first which
is not readable as a number (for example 5a3) is read as MISSING.

When the first word in a column is not a number or a code for MISSING,
the corresponding variable is a factor, by default, with a level for
each distinct word in the column.  The factor has the original words in
the file as row labels.  With 'factor:F' as an argument, the column is
read as a CHARACTER variable instead of a factor.

FileName can take two forms:
 A quoted string or CHARACTER scalar whose value is the file name.  In
 a version with windows (Macintosh, Windows, Motif), when FileName is
 "", you can select the file using a dialog box.  A variant is
 keyword phrase file:FileName.

 The keyword phrase string:CharVector, where CharVector is a CHARACTER
 scalar or vector which is "read" instead of a file.  When
 length(CharVector) > 1, each element starts a new line.  Any newline
 characters '\n' terminate lines. In windowed versions, string:CLIPBOARD
 can be useful.  See vecread(), 'CLIPBOARD'.

You can use most vecread() keywords 'quiet', 'silent', 'stop', 'skip',
'skipthru', 'go', 'quiet', 'echo', and 'n', but not 'bypass', 'bywords',
'bylines', 'bychars', 'byfields' and 'realorchar'.  See topic
'vecread_keys'.

See also readcols(), vecread(), 'vecread_files'.


Gary Oehlert 2003-01-15