sparklines
everywhere!
#921
JanMarvin
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
To use sparklines <- function(x, col_names = TRUE, rows = TRUE, cols = TRUE) {
out <- NULL
if (rows) {
row <- seq_len(nrow(x))
tmp <- vapply(row, function(ll) {
sqref <- wb_dims(x = x, rows = ll, col_names = col_names)
dims <- wb_dims(x = x, rows = ll, cols = ncol(x) + 1L, col_names = col_names)
create_sparklines("Sheet 1", sqref, dims)
}, NA_character_)
out <- c(out, tmp)
}
if (cols) {
col <- seq_len(ncol(x))
tmp <- vapply(col, function(ll) {
sqref <- wb_dims(x = x, cols = ll, col_names = col_names)
dims <- wb_dims(x = x, cols = ll, rows = nrow(x) + 1L, col_names = col_names)
create_sparklines("Sheet 1", sqref, dims)
}, NA_character_)
out <- c(out, tmp)
}
out
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A nice way to visualize data is via
sparkline
s. Sinceopenxlsx2
already provides the functionality to create them, it is also possible to add them wherever you want. Find below an example adding sparklines next to columns and rows of a data object.[Edit:] Fixed a thinko in my initial solution, that was avoided in @olivroys solution below
Beta Was this translation helpful? Give feedback.
All reactions