cards {lazy.irtx} | R Documentation |
Convert a string to matrix
For those who miss the luxury of using spaces as delimitters.
cards(a, rnameroot = "r", cnameroot = "c", header = 0, missing = "NA", nummat = 0, debug = 0)
a |
string which contains the body of the matrix with \nr. |
rnameroot |
root of the row names when header=0 |
cnameroot |
root of the column names when header=0 |
header |
= 1 if the string has row/col names |
missing |
a string which indicates missing values: "NA" or "." |
nummat |
not yet available |
debug |
= 1 to dump intermediate result |
Use space ( blank characters ) or a comma as delimiters.
Two or more commas indicate the existence of missing values in between.
The last comma indicates one element is missing at the end.
Blank lines will be neglected.
CARDS=" v1 v2 v3
s1 11 12 13
s2 21 22 23
s3 31 32 33"
A=cards( CARDS, header=1 )
A will be a 3 x 3 matrix with row and column names.
a matrix or data.frame
CARDS=" v1 v2 v3 s1 11 12 13 s2 21 22 23 s3 NA 32 33" cards( CARDS, header=1 ) CARDS=" v1 v2 v3 s1, 11, 12, 13 s2, 21, 22, 23 s3,, 32, 33" cards( CARDS, header=1 ) CARDS="v0 v1 v2 v3 s1 11 12 13 s2 21 22 23 s3 . 32 33" cards( CARDS, header=1, missing="." ) CARDS=" 11 12 13 21 22 23 NA 32 33 " cards( CARDS )