Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: xplore
See also: read write readascii writem

Quantlet: readm
Description: readm reads mixed data from a file.

Usage: z = readm (filename {, separators, multisep, rrow, rcol, onlytype})
Input:
filename name of the data file
separators an optional string that contains the data separator (default = " \t\n"); if the string is empty, the default value is used
multisep an optional scalar, more separators following each other are consider as one if it is non-zero (default = 1)
rrow an optional p1 x 2 matrix (if you enter a scalar, it will be ignored) specifies, which rows should be read. Every row consists of two numbers, r1 and r2: 1) if both numbers are positive, they specify that rows with indices {r1,...,r2} should be read in; 2) if both number are negative, they specify that rows with indices {|r1|,...,|r2|} should be excluded from reading; 3) it is not possible to mix inclusion and exclusion conditions. If the parameter is omitted or is a scalar, all rows are read.
rcol an optional p2 x 2 matrix (if you enter a scalar, it will be ignored) specifies, which columns should be read. Every column consists of two numbers, r1 and r2: 1) if both numbers are positive, they specify that columns with indices {r1,...,r2} should be read in; 2) if both number are negative, they specify that columns with indices {|r1|,...,|r2|} should be excluded from reading; 3) it is not possible to mix inclusion and exclusion conditions. If the parameter is omitted or is a scalar, all columns are read.
onlytype an optional scalar; if entered, the quantlet assumes that all columns have the type given by this parameter (0 stands for numbers and 1 for strings)
Output:
z.type (p+q) vector, types of columns in file
z.double n x p matrix, numerical vectors; this component equals zero if p == 0, i.e., when there are no numerical columns in the file
z.text n x q matrix, text vectors; this component contains an empty string if q == 0, i.e., when there are no text columns in the file

Note:

Example:
library("xplore")
readm("mixed.dat")

Result:
Contents of string
[1,] "readm: Found    2 line(s) and    7 column(s)"

Contents of z.type
[1,]        0
[2,]        0
[3,]        0
[4,]        0
[5,]        1
[6,]        0
[7,]        0

Contents of z.double
[1,]        1        2        3        4      4.5     +NAN
[2,]        5        6        7        0      6.7      8.9

Contents of z.text
[1,] "hallo"
[2,] "hallo_again"
Example:
library("xplore")
readm("mixed.dat", "", 1, 0, 5~7)

Result:
The same example as before, but now the fifth to the seventh
column are read. Notice that the separator is an empty
string, so that the default separators are used.

Contents of string
[1,] "readm: Found    2 line(s) and    3 column(s)"

Contents of z.type
[1,]        1
[2,]        0
[3,]        0

Contents of z.double
[1,]      4.5     +NAN
[2,]      6.7      8.9

Contents of z.text
[1,] "hallo"
[2,] "hallo_again"



Author: S. Klinke, P. Cizek, 20020325
(C) MD*TECH Method and Data Technologies, 05.02.2006