EVOLUTION-MANAGER
Edit File: symnum.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Symbolic Number Coding</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for symnum {stats}"><tr><td>symnum {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Symbolic Number Coding</h2> <h3>Description</h3> <p>Symbolically encode a given numeric or logical vector or array. Particularly useful for visualization of structured matrices, e.g., correlation, sparse, or logical ones. </p> <h3>Usage</h3> <pre> 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)) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>numeric or logical vector or array.</p> </td></tr> <tr valign="top"><td><code>cutpoints</code></td> <td> <p>numeric vector whose values <code>cutpoints[j]</code> <i> == c[j]</i> (<em>after</em> augmentation, see <code>corr</code> below) are used for intervals.</p> </td></tr> <tr valign="top"><td><code>symbols</code></td> <td> <p>character vector, one shorter than (the <em>augmented</em>, see <code>corr</code> below) <code>cutpoints</code>. <code>symbols[j]</code><i> == s[j]</i> are used as ‘code’ for the (half open) interval <i>(c[j], c[j+1]]</i>. </p> <p>When <code>numeric.x</code> is <code>FALSE</code>, i.e., by default when argument <code>x</code> is <code>logical</code>, the default is <code>c(".","|")</code> (graphical 0 / 1 s).</p> </td></tr> <tr valign="top"><td><code>legend</code></td> <td> <p>logical indicating if a <code>"legend"</code> attribute is desired.</p> </td></tr> <tr valign="top"><td><code>na</code></td> <td> <p>character or logical. How <code><a href="../../base/html/NA.html">NA</a>s</code> are coded. If <code>na == FALSE</code>, <code>NA</code>s are coded invisibly, <em>including</em> the <code>"legend"</code> attribute below, which otherwise mentions NA coding.</p> </td></tr> <tr valign="top"><td><code>eps</code></td> <td> <p>absolute precision to be used at left and right boundary.</p> </td></tr> <tr valign="top"><td><code>numeric.x</code></td> <td> <p>logical indicating if <code>x</code> should be treated as numbers, otherwise as logical.</p> </td></tr> <tr valign="top"><td><code>corr</code></td> <td> <p>logical. If <code>TRUE</code>, <code>x</code> contains correlations. The cutpoints are augmented by <code>0</code> and <code>1</code> and <code>abs(x)</code> is coded.</p> </td></tr> <tr valign="top"><td><code>show.max</code></td> <td> <p>if <code>TRUE</code>, or of mode <code>character</code>, the maximal cutpoint is coded especially.</p> </td></tr> <tr valign="top"><td><code>show.min</code></td> <td> <p>if <code>TRUE</code>, or of mode <code>character</code>, the minimal cutpoint is coded especially.</p> </td></tr> <tr valign="top"><td><code>abbr.colnames</code></td> <td> <p>logical, integer or <code>NULL</code> indicating how column names should be abbreviated (if they are); if <code>NULL</code> (or <code>FALSE</code> and <code>x</code> has no column names), the column names will all be empty, i.e., <code>""</code>; otherwise if <code>abbr.colnames</code> is false, they are left unchanged. If <code>TRUE</code> or integer, existing column names will be abbreviated to <code><a href="../../base/html/abbreviate.html">abbreviate</a>(*, minlength = abbr.colnames)</code>.</p> </td></tr> <tr valign="top"><td><code>lower.triangular</code></td> <td> <p>logical. If <code>TRUE</code> and <code>x</code> is a matrix, only the <em>lower triangular</em> part of the matrix is coded as non-blank.</p> </td></tr> <tr valign="top"><td><code>diag.lower.tri</code></td> <td> <p>logical. If <code>lower.triangular</code> <em>and</em> this are <code>TRUE</code>, the <em>diagonal</em> part of the matrix is shown.</p> </td></tr> </table> <h3>Value</h3> <p>An atomic character object of class <code><a href="../../base/html/noquote.html">noquote</a></code> and the same dimensions as <code>x</code>. </p> <p>If <code>legend</code> is <code>TRUE</code> (as by default when there are more than two classes), the result has an attribute <code>"legend"</code> containing a legend of the returned character codes, in the form </p> <p style="text-align: center;"><i>c[1] \sQuote{s[1]} c[2] \sQuote{s[2]} … \sQuote{s[n]} c_[n+1]</i></p> <p>where <i>c[j]</i><code> = cutpoints[j]</code> and <i>s[j]</i><code> = symbols[j]</code>. </p> <h3>Note</h3> <p>The optional (mostly logical) arguments all try to use smart defaults. Specifying them explicitly may lead to considerably improved output in many cases. </p> <h3>Author(s)</h3> <p>Martin Maechler <a href="mailto:maechler@stat.math.ethz.ch">maechler@stat.math.ethz.ch</a></p> <h3>See Also</h3> <p><code><a href="../../base/html/character.html">as.character</a></code>; <code><a href="../../graphics/html/image.html">image</a></code> </p> <h3>Examples</h3> <pre> ii <- setNames(0:8, 0:8) symnum(ii, cut = 2*(0:4), sym = c(".", "-", "+", "$")) symnum(ii, cut = 2*(0:4), sym = c(".", "-", "+", "$"), show.max = TRUE) symnum(1:12 %% 3 == 0) # --> "|" = TRUE, "." = FALSE for logical ## Pascal's Triangle modulo 2 -- odd and even numbers: N <- 38 pascal <- t(sapply(0:N, function(n) round(choose(n, 0:N - (N-n)%/%2)))) rownames(pascal) <- rep("", 1+N) # <-- to improve "graphic" symnum(pascal %% 2, symbols = c(" ", "A"), numeric = FALSE) ##-- Symbolic correlation matrices: symnum(cor(attitude), diag = FALSE) symnum(cor(attitude), abbr. = NULL) symnum(cor(attitude), abbr. = FALSE) symnum(cor(attitude), abbr. = 2) symnum(cor(rbind(1, rnorm(25), rnorm(25)^2))) symnum(cor(matrix(rexp(30, 1), 5, 18))) # <<-- PATTERN ! -- symnum(cm1 <- cor(matrix(rnorm(90) , 5, 18))) # < White Noise SMALL n symnum(cm1, diag = FALSE) symnum(cm2 <- cor(matrix(rnorm(900), 50, 18))) # < White Noise "BIG" n symnum(cm2, lower = FALSE) ## NA's: Cm <- cor(matrix(rnorm(60), 10, 6)); Cm[c(3,6), 2] <- NA symnum(Cm, show.max = NULL) ## Graphical P-values (aka "significance stars"): pval <- rev(sort(c(outer(1:6, 10^-(1:3))))) symp <- symnum(pval, corr = FALSE, cutpoints = c(0, .001,.01,.05, .1, 1), symbols = c("***","**","*","."," ")) noquote(cbind(P.val = format(pval), Signif = symp)) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>