Nothing
## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
warning = FALSE,
message = FALSE
)
## ----load---------------------------------------------------------------------
library(Rbearcat)
## ----dollar-------------------------------------------------------------------
bcat_fmt_dollar(c(1234.5, 67890, 0.99))
## ----dollar-neg---------------------------------------------------------------
bcat_fmt_dollar(c(-500, 1200))
bcat_fmt_dollar(c(-500, 1200), style_negative = "parens")
## ----dollar-scale-------------------------------------------------------------
bcat_fmt_dollar(c(150000, 275000), scale = 1e-3, accuracy = 1, suffix = "K")
## ----percent------------------------------------------------------------------
bcat_fmt_percent(c(0.0523, 0.1, 0.9871))
## ----percent-prescaled--------------------------------------------------------
bcat_fmt_percent(c(5.23, 10, 98.71), scale = 1)
## ----percent-accuracy---------------------------------------------------------
bcat_fmt_percent(c(0.05234, 0.10011), accuracy = 0.01)
## ----comma--------------------------------------------------------------------
bcat_fmt_comma(c(1000, 50000, 1234567))
## ----comma-suffix-------------------------------------------------------------
bcat_fmt_comma(c(5000, 10000, 80000), scale = 1e-3, accuracy = 1, suffix = "K")
## ----scientific---------------------------------------------------------------
bcat_fmt_scientific(c(0.00012, 3456789, 1.5e10))
## ----scientific-digits--------------------------------------------------------
bcat_fmt_scientific(c(123456, 789012), digits = 2)
## ----date---------------------------------------------------------------------
bcat_fmt_date(Sys.Date())
bcat_fmt_date(c("2024-01-15", "2025-06-30"))
## ----date-custom--------------------------------------------------------------
bcat_fmt_date("2025-12-25", format = "%d %b %Y")
bcat_fmt_date("2025-12-25", format = "%m/%d/%Y")
## ----pvalue-------------------------------------------------------------------
bcat_fmt_pvalue(c(0.54, 0.045, 0.001, 0.00001))
## ----pvalue-prefix------------------------------------------------------------
bcat_fmt_pvalue(c(0.032, 0.0001), add_p = TRUE)
## ----pvalue-accuracy----------------------------------------------------------
bcat_fmt_pvalue(c(0.0456, 0.00012), accuracy = 0.01)
## ----inline-example-----------------------------------------------------------
avg_price <- 12345.67
pct_change <- 0.052
my_pval <- 0.003
bcat_fmt_dollar(avg_price)
bcat_fmt_percent(pct_change)
bcat_fmt_pvalue(my_pval, add_p = TRUE)
## ----scale-labels-------------------------------------------------------------
library(ggplot2)
set_UC_geoms()
ggplot(economics, aes(date, pce)) +
geom_line() +
scale_y_continuous(labels = bcat_fmt_dollar) +
labs(title = "Personal Consumption Expenditure",
x = NULL, y = "Billions ($)") +
theme_UC()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.