| compact01 | R Documentation |
Of a 0-1 i.e., binary vector, using symnum(z == 1),
produce a compact “visual” character representation
for human consumption.
No rocket science, but a nice example of combining basic R idioms.
compact01(z, ncol = 50L)
z |
a vector, typically of |
ncol |
a positive integer, specifying the number of “columns” of the result. |
a character matrix Ch, K \times 1,
where each row is a string of "." and "|" of string length
typically ncol, but for short z, will have
nchar(Ch[1,1]) == min(ncol, length(z)).
Martin Maechler
symnum
set.seed(12)
z <- rbinom(120, size = 1, prob = 1/4)
(compact01(z) -> Ch)
compact01(z, 20)
## "visualize" a TRUE/FALSE property
x <- rnorm(150)
compact01(abs(x) > 1.5)
stopifnot(identical(0:1, dim(compact01(integer()))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.