show | R Documentation |
Show methods for onions
## S4 method for signature 'onion'
show(object)
onion_show(x,
comp = getOption("show_onions_compactly"),
h = getOption("show_onions_horizontally")
)
comp_names(x)
x , object |
Onions |
comp |
Boolean, with |
h |
Boolean, with |
TLDR: the print method uses onion_show()
. This converts its
argument to an appropriate matrix by adjusting the column names if
necessary. This matrix is printed to the console using the standard
print method for matrices, and hence is sensitive to
getOption("digits")
.
Default behaviour is to print by rows. To print by columns, set
option show_onions_horizontally
to TRUE
:
options("show_onions_horizontally" = TRUE)
Any non-TRUE
value (including NULL
and its being unset)
will restore the default.
Similarly, to show onions compactly, set option
show_onions_compactly
to TRUE
:
options("show_onions_compactly" = TRUE)
This option works best for simple onions with integer entries (or at least values with few decimal places), and especially if there are many zero entries.
Function onion_show()
is a helper function, not really intended
for the end-user.
The “names” of the components of an onion (viz Re
,
i
, j
, k
for quaternions and Re
, i
,
j
, k
, l
,il
,jl
,kl
for
octonions) are given by function comp_names()
which takes
either a character string or an onion.
The print method for onionmat
objects is also sensitive to
these options.
Robin K. S. Hankin
x <- roct(15)
x #default
options("show_onions_horizontally" = TRUE)
roct(4)
options("show_onions_horizontally" = FALSE) # restore default
options("show_onions_compactly" = TRUE)
x <- as.quaternion(matrix(sample(c(0,0,0,-1,1),80,replace=TRUE),4,20))
options("show_onions_compactly" = FALSE) # restore default
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.