Library: | xplore |
See also: | readxls readm writem readcsv readcsvm writecsv readascii read write |
Quantlet: | readxlsm | |
Description: | reads mixed data from a MS Excel file |
Usage: | z=readxlsm(filename{,rrow,rcol}) | |
Input: | ||
filename | string, name of the file | |
rrow | (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 | (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. | |
Output: | ||
z.type | (p+q) x 1 vector, types of columns in the 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 |
The parameter z.type contains the recognized type of the corresponding vector in the file (0 represents number, 1 text vector). Note that even if there is only one text element in some column (and other elements in this column are numbers), this column will be represented as a text column. The signs " " or "." are also represented as text.
If there are no numerical columns, z.double will contain zero. If there are no text columns, z.text will be an empty string.
The columns and rows specified by matrices rcol and rrow are read and output in the same order as they are in the file, i.e., as if the entries of rcol and rrow are sorted.
Redistributions of any form whatsoever must retain the following acknowledgment: This product includes software developed by David Giffin <david@giffin.org>.
library("xplore") readxlsm("example.xls")
Contents of string [1,] "readm: Found 3 line(s) and 3 column(s)" Contents of z.type [1,] 1 [2,] 0 [3,] 1 Contents of z.double [1,] 5.4 [2,] 4.6 [3,] +NAN Contents of z.text [1,] "hallo" "John" [2,] "" " " [3,] "Hi" "George"
library("xplore") readxlsm("example.xls", 0, -1~-1)
The same example as before, but now the first column is omitted. Notice that the separator is an empty string, so the default separators are used. Contents of string [1,] "readm: Found 3 line(s) and 2 column(s)" Contents of z.type [1,] 0 [2,] 1 Contents of z.double [1,] 5.4 [2,] 4.6 [3,] +NAN Contents of z.text [1,] "John" [2,] " " [3,] "George"