readCA: Function for reading a covering array from a text file

View source: R/readCA.R

readCAR Documentation

Function for reading a covering array from a text file

Description

reads a text file into a matrix of class ca (for covering array)

Usage

readCA(path, flexible.symbols=c("*","-","."), comment.symbol="C",
ninstruct=1, skiplines=0, ignore.chars=NULL, nosep=FALSE, origin=NULL, ...)

funmakefromstrings(stringvec)

Arguments

path

a character string that specifies the path, including the file name; see Section Details for requirements the file must satisfy.

flexible.symbols

characters to be treated as flexible values (will be set to NA)

comment.symbol

character that starts a comment line

ninstruct

integer, number of lines with instructions (1 or 0)

skiplines

integer, number of lines with no readable instructions and no defined comment character that should nevertheless be skipped; those are assumed to be above the instructions line

ignore.chars

NULL, or characters to be removed from data lines (e.g., [ and ])

nosep

logical; set to TRUE, if the data lines do not contain separators and each character is a data value

origin

character string to be attached to the output array as origin-attribute; if NULL, the path and filename information is used

...

further arguments for function read.table, which is used separately for each line (after reading them with readLines)

stringvec

vector of n character strings of equal lengths (k, say). The character strings should consist of digits and small letters. Digits will remain unchanged, and the letters a to z will be replaced by numbers 10 to 35.

Value

The output object of readCA is a matrix of class ca. The output object of funmakefromstrings is an n x k matrix of numeric values. funmakefromstrings is used by readCA, but can also be used on its own.

Details

The file fn may start with comment lines that begin with a comment symbol, and an instruction line.
The first line after removing the comments lines contains instructions about the file content, in the form N k v1^k1 v2^k2 ... It is permissible for the instructions line to have a single string without blanks or ^ (e.g., for the strength) after the exponential notation for the columns; this will be ignored in the reading process. ninstruct=0 indicates that there is no instruction line.
All columns of the array must have the same starting value, i.e., start all with 0 or all with 1.

Examples

## values start with 0
funmakefromstrings(c("0123456789abc", "1032547698cba"))
## values start with 1
funmakefromstrings(c("123456789abc", "132547698cba"))
## values start with 4 (would usually not make sense)
funmakefromstrings(c("456789abc", "547698cba"))


CAs documentation built on Nov. 29, 2026, 1:06 a.m.