symnum: Symbolic Number Coding

Description Usage Arguments Value Note Author(s) See Also Examples

Description

Symbolically encode a given numeric or logical vector or array. Particularly useful for visualization of structured matrices, e.g., correlation, sparse, or logical ones.

Usage

 1 2 3 4 5 6 7 8 9 10 symnum(x, cutpoints = c(0.3, 0.6, 0.8, 0.9, 0.95), symbols = if(numeric.x) c(" ", ".", ",", "+", "*", "B") else c(".", "|"), legend = length(symbols) >= 3, na = "?", eps = 1e-5, numeric.x = is.numeric(x), corr = missing(cutpoints) && numeric.x, show.max = if(corr) "1", show.min = NULL, abbr.colnames = has.colnames, lower.triangular = corr && is.numeric(x) && is.matrix(x), diag.lower.tri = corr && !is.null(show.max))

Arguments

 x numeric or logical vector or array. cutpoints numeric vector whose values cutpoints[j] == c[j] (after augmentation, see corr below) are used for intervals. symbols character vector, one shorter than (the augmented, see corr below) cutpoints. symbols[j] == s[j] are used as ‘code’ for the (half open) interval (c[j], c[j+1]]. When numeric.x is FALSE, i.e., by default when argument x is logical, the default is c(".","|") (graphical 0 / 1 s). legend logical indicating if a "legend" attribute is desired. na character or logical. How NAs are coded. If na == FALSE, NAs are coded invisibly, including the "legend" attribute below, which otherwise mentions NA coding. eps absolute precision to be used at left and right boundary. numeric.x logical indicating if x should be treated as numbers, otherwise as logical. corr logical. If TRUE, x contains correlations. The cutpoints are augmented by 0 and 1 and abs(x) is coded. show.max if TRUE, or of mode character, the maximal cutpoint is coded especially. show.min if TRUE, or of mode character, the minimal cutpoint is coded especially. abbr.colnames logical, integer or NULL indicating how column names should be abbreviated (if they are); if NULL (or FALSE and x has no column names), the column names will all be empty, i.e., ""; otherwise if abbr.colnames is false, they are left unchanged. If TRUE or integer, existing column names will be abbreviated to abbreviate(*, minlength = abbr.colnames). lower.triangular logical. If TRUE and x is a matrix, only the lower triangular part of the matrix is coded as non-blank. diag.lower.tri logical. If lower.triangular and this are TRUE, the diagonal part of the matrix is shown.

Value

An atomic character object of class noquote and the same dimensions as x.

If legend is TRUE (as by default when there are more than two classes), the result has an attribute "legend" containing a legend of the returned character codes, in the form

c \sQuote{s} c \sQuote{s} … \sQuote{s[n]} c_[n+1]

where c[j] = cutpoints[j] and s[j] = symbols[j].

Note

The optional (mostly logical) arguments all try to use smart defaults. Specifying them explicitly may lead to considerably improved output in many cases.

Author(s)

Martin Maechler [email protected]