formatHTML | R Documentation |
Format any character string to HTML or markdown format. We
recommend using this format with the ggtext::geom_richtext
function to format text in ggplot2
objects.
This function lets the user format numerical values nicely
formatHTML(text, color = "black", size = 20, bold = FALSE)
formatNum(
x,
decimals = 2,
signif = NULL,
type = Sys.getenv("LARES_NUMFORMAT"),
pre = "",
pos = "",
sign = FALSE,
abbr = FALSE,
...
)
text |
Character. Strings to format. |
color |
Character. Hex colour code. |
size |
Numeric. Text size. |
bold |
Boolean. Should the text be bold? |
x |
Numerical Vector |
decimals |
Integer. Amount of decimals to display. If set to
|
signif |
Integer. Rounds the values in its first argument to the specified number of significant digits. |
type |
Integer. |
pre , pos |
Character. Add string before or after number. |
sign |
Boolean. Add |
abbr |
Boolean. Abbreviate using num_abbr()? You can use
the ‘decimals' parameter to set abbr’s |
... |
Additional lazy eval parameters. |
String with format characters included.
Character. String vector with reformatted continuous numbers
Other Tools:
autoline()
,
bind_files()
,
bring_api()
,
chr2num()
,
db_download()
,
db_upload()
,
export_plot()
,
export_results()
,
files_functions()
,
font_exists()
,
formatColoured()
,
get_credentials()
,
glued()
,
grepm()
,
h2o_selectmodel()
,
haveInternet()
,
image_metadata()
,
importxlsx()
,
ip_data()
,
json2vector()
,
list_cats()
,
listfiles()
,
mail_send()
,
markdown2df()
,
move_files()
,
msplit()
,
myip()
,
quiet()
,
read.file()
,
statusbar()
,
tic()
,
try_require()
,
updateLares()
,
warnifnot()
,
what_size()
Other Data Wrangling:
balance_data()
,
categ_reducer()
,
cleanText()
,
date_cuts()
,
date_feats()
,
file_name()
,
holidays()
,
impute()
,
left()
,
normalize()
,
num_abbr()
,
ohe_commas()
,
ohse()
,
quants()
,
removenacols()
,
replaceall()
,
replacefactor()
,
textFeats()
,
textTokenizer()
,
vector2text()
,
year_month()
,
zerovar()
formatHTML("Text test", color = "#000000")
formatHTML(c(123, 456), color = "orange", size = 120, bold = TRUE)
# If you want to use it with \code{ggtext}:
## Not run:
col1 <- "grey"
col2 <- "orange"
pt <- data.frame(
label = paste0(
formatHTML(123, color = col2, size = 120, bold = TRUE), "<br/>",
formatHTML("of children had a", col1), "<br/>",
formatHTML("traditional stay-at-home mom", color = col2, bold = TRUE), "<br/>",
formatHTML(paste0("in 2012, compared to ", 321, " in 1970"), color = col1)
)
)
ggplot(pt, aes(x = 0, y = 0)) +
ggtext::geom_richtext(
aes(label = label),
hjust = 0,
label.color = NA,
lineheight = 1.5
) +
xlim(0, 0.01) +
theme_void()
## End(Not run)
formatNum(1.23456, decimals = 3)
formatNum(1.23456, type = 1)
formatNum(1.23456, pre = "$", pos = "/person")
formatNum(123456, abbr = TRUE)
formatNum(1234567890, abbr = TRUE, signif = 2)
formatNum(1234567890, decimals = 0, abbr = TRUE)
formatNum(c(-3:3), sign = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.