shortenStrings | R Documentation |
Some axis labels are sometimes just too long and printing them will either squeeze the actual plot (ggplot) or make the labels disappear beyond the margins (graphics::plot) One ad-hoc way of avoiding this is to shorten the names, hoping they are still meaningful to the viewer.
shortenStrings(x, max_len = 20, verbose = TRUE, allow_duplicates = FALSE)
x |
Vector of input strings |
max_len |
Maximum length allowed |
verbose |
Print which strings were shortened |
allow_duplicates |
If shortened strings are not discernible any longer, consider the short version valid (not the default), otherwise (default) return the full string (–> no-op) |
This function should be applied AFTER you tried more gentle methods, such as delLCP
or simplifyNames
.
A vector of shortened strings
delLCP
, simplifyNames
r = shortenStrings(c("gamg_101", "gamg_101230100451", "jurkat_06_100731121305", "jurkat_06_1"))
all(r == c("gamg_101", "gamg_101230100..", "jurkat_06_1007..", "jurkat_06_1"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.