n2c: Show absolute values as characters, prepare for plotting

Description Usage Arguments Value Note Author(s) Examples

Description

n2c takes a numerical vector or matrix and represents it as single characters, with attribute legend. indexLine generates a string with dots, ";", and digits, usable as x-label in n2cCompact: .....;....1....;....2.. n2cCompact combines n2c and indexLine to generate a vector of strings good for printing numerical matrices. charMat processes the output from n2cCompact and returns vectors x, y, tx of equal lengths for input to pltCharMat. explainLegend gives a more readable version of attribute legend.

Usage

1
2
3
4
5
  n2c(x, symm = FALSE)
  indexLine(n)
  n2cCompact(x, symm=FALSE)
  charMat(cc)
  explainLegend()

Arguments

x

A numerical vector or matrix.

symm

If symm = TRUE then upper triangle will be suppressed.

n

integer, length of string wanted

cc

output from n2cCompact, input to charMat

Value

n2c Representation of x as a single-character matrix, as explained in attribute legend. n2cCompact pack charMat list(x,y,txt)

Note

Empty places due to symm = TRUE are filled with " ".

Author(s)

Christian W. Hoffmann <christian@echoffmann.ch>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
n2c(c(10e20,-10e5,10,(10:0)/10,0.05)) 
#   "X" "6" "1" "0" "&" "%" "#" "*" "=" "+" "-" ":" "," " "
# attr(,"legend")
# [1] ">=1:log, >=0. 9& 8% 7# 6* 5= 4+ 3- 2: 1, 05. ' ' "

n2c(matrix(c(10e20,10e5,20,10,0.7,0.6,0,0.5,0.1),3,3),FALSE)
#      [,1] [,2] [,3]
# [1,] "X"  "1"  " " 
# [2,] "5"  "#"  "=" 
# [3,] "1"  "*"  "," 
# attr(,"legend")
# [1] ">=1: log, >=0. 9& 8% 7# 6* 5= 4+ 3- 2: 1, 05. ' ' "
m <- matrix(rnorm(500),nrow=50,ncol=10)
n2c(m,symm=TRUE)
indexLine(ncol(m))
(n2 <- n2cCompact(m, symm=FALSE))
charMat(n2)
explainLegend() # 

cwhmisc documentation built on May 1, 2019, 7:55 p.m.