Description Usage Arguments Details Value Examples
View source: R/labels-format.R
basepair_label()
automatically scales and labels numbers
with an appropriate SI suffix, e.g. "kb" for values ≥ 1e3, "Mb" for
≥ 1e6, "Gb" for ≥ 1e9.
1 2 3 4 5 6 7 8 9 | label_basepair(
accuracy = NULL,
unit = "b",
sep = NULL,
labelsmall = FALSE,
...
)
basepair_label(x)
|
accuracy |
A number to round to. Use (e.g.) Applied to rescaled data. |
unit |
Optional units specifier. |
sep |
Separator between number and SI unit. Defaults to |
labelsmall |
A |
... |
Other arguments passed on to |
x |
A vector to label. Can either be |
The label_basepair()
function is a function factory that
returns a labelling function, i.e. a function that takes a vector x
and returns a character vector of length(x) giving a label for each input
value. The basepair_label()
function is the default labeller from
label_basepair()
for convenience.
Note that these functions don't attempt to format numbers smaller than 1, as the units millibasepair and centibasepairs do not make sense.
When used in combination with
scale_(x|y)_genomic
, these labelling
functions work best as the minor_labels
argument.
A function
for label_basepair()
or a character vector
of labels for basepair_label()
.
1 2 3 4 5 6 7 8 | require(scales)
# The following labels are equivalent
demo_continuous(c(1, 1e9), label = label_basepair())
demo_continuous(c(1, 1e9), label = basepair_label)
# When the label 'bp' is preffered over 'b'
demo_continuous(c(1, 1e9), label = label_basepair(unit = "bp"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.