-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tfd()
and tfb()
print not formatting correctly
#37
Comments
tfd
and tfb
print not formatting correcttfd
and tfb
print not formatting correctly
tfd
and tfb
print not formatting correctlytfd()
and tfb()
print not formatting correctly
not gonna do this now, but agree that a better print method would be worthwhile. |
maybe: sparklines instead? (https://rosettacode.org/wiki/Sparkline_in_unicode) bars <- intToUtf8(seq(0x2581, 0x2588), multiple = T) # ▁ ▂ ▃ ▄ ▅ ▆ ▇ █
n_chars <- length(bars)
sparkline <- function(numbers) {
mn <- min(numbers)
mx <- max(numbers)
interval <- mx - mn
bins <- sapply(
numbers,
function(i)
bars[[1 + min(n_chars - 1, floor((i - mn) / interval * n_chars))]]
)
sparkline <- paste0(bins, collapse = "")
return(sparkline)
}
sparkline(c(1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1))
sparkline(c(1.5, 0.5, 3.5, 2.5, 5.5, 4.5, 7.5, 6.5))
sparkline(c(0, 999, 4000, 4999, 7000, 7999))
sparkline(c(0, 0, 1, 1))
sparkline(c(0, 1, 19, 20)) [1] "▂▁▄▃▆▅█▇" |
The sparkbar implementation from the cli package looks quite nice https://cli.r-lib.org/reference/spark_bar.html and the implementation is quite concise to copy and paste: https://github.com/r-lib/cli/blob/HEAD/R/spark.R#L64 |
Yeah, but since it's just like 20 lines I think we should copy/adjust (with attribution) and avoid the dependency. Challenge I think will be to make this look good/show up in e.g. things to think about:
... what else? |
Spacing after the commas is not working for every position and perhaps a space after the semicolon makes reading easier.
Created on 2024-01-05 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: