What does “useless-but-useful” even mean?
These aren’t the functions that get you promoted.
They’re the tiny delights that make your daily R life 10× more fun and 3 seconds faster.
Copy them once. Paste them into your ~/.Rprofile. Never look back.
“I added #3 and now I smile every time my script finishes. 10/10 would recommend.”
— @hadleywickham (probably)
Pick your daily joy
emoji_progress()
Boring progress bars are dead. Meet your new favorite console companion.
emoji_progress <- function(total = 50, message = "Crunching data") {
library(cli)
cli_progress_bar(message, total = total,
format = "{cli::pb_bar} {cli::pb_percent} {cli::pb_current}/{cli::pb_total} {emoji}",
.auto_close = FALSE)
emojis <- c("🚀","🔥","⚡","🌟","💎")
for (i in seq_len(total)) {
Sys.sleep(0.08)
cli_progress_update(extra = list(emoji = sample(emojis, 1)))
}
cli_progress_done()
cat("✅ Done!\n")
}
confetti()
Because every successful script deserves a party.
confetti <- function(times = 25) {
colors <- c("\033[38;5;196m", "\033[38;5;202m", "\033[38;5;226m",
"\033[38;5;46m", "\033[38;5;51m")
symbols <- c("✨","🎉","🚀","💥","⭐","🦄")
for (i in 1:times) {
cat(sample(colors, 1), sample(symbols, 1), " ")
Sys.sleep(0.03)
}
cat("\033[0m\n\n🎊 MISSION ACCOMPLISHED! You're unstoppable.\n\n")
}
r_fortune()
Your daily dose of R wisdom (or dad jokes).
r_fortune <- function() {
fortunes <- c(
"The best plot is the one you never had to debug.",
"Always check your data. Even your coffee.",
"dplyr::mutate() is just base R with better marketing.",
"If it works on the first try, you probably did something wrong.",
"R is love. R is life. R is occasionally a nightmare."
)
cat("🍪 Today's R fortune:\n\n")
cat(" “", sample(fortunes, 1), "”\n\n")
}
quick_email()
One-liner to send beautiful reports from R.
quick_email <- function(to, subject = "Daily Report", df) {
box::use(
blastula[compose_email, md, smtp_send, creds_key],
gt[gt, as_raw_html],
glue[glue]
)
email <- compose_email(
body = md(
glue("
## Your report is ready! 🎉
**Rows:** {nrow(df)} | **Columns:** {ncol(df)}
{gt(df) |> as_raw_html()}
")
)
)
smtp_send(email, to = to, subject = subject, credentials = creds_key())
cat("📨 Email sent to", to, "!\n")
}
random_xkcd()
Instant break when your brain melts.
random_xkcd <- function() {
num <- sample(1:3000, 1)
url <- paste0("https://xkcd.com/", num)
browseURL(url)
cat("🃏 XKCD #", num, " opened. Go touch grass (or at least laugh).\n")
}