-
Notifications
You must be signed in to change notification settings - Fork 39
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
Show colour in glimpse()
#658
Comments
Good idea. Would you like to contribute a PR? What kind of guidance would you need? |
I also think it would be a nice feature to have NAs have more color for tables. I can send a PR if you'd like. The coloring of the commas seems like some more intensive work. My thoughts format_glimpse.default <- function(x, ...) {
dims <- dim(x)
if (!is.null(dims)) {
dims_out <- paste0(dims, collapse = " x ")
paste0("<", class(x)[[1]], "[", dims_out, "]>")
} else {
out <- format(x, trim = TRUE, justify = "none")
out[is.na(x)] <- crayon_red(NA)
out
}
}
format_glimpse.character <- function(x, ...) {
out <- encodeString(as.character(x), quote = '"')
out[is.na(x)] <- crayon_red(NA)
out
}
format_glimpse.factor <- function(x, ...) {
if (any(grepl(",", levels(x), fixed = TRUE))) {
out <- encodeString(as.character(x), quote = '"')
} else {
out <- format(x, trim = TRUE, justify = "none")
}
out[is.na(x)] <- crayon_red(NA)
out
} |
The The displayed value are separated with comas, for more clarity we wish to color these comas, using the same color used to format the column types. |
I'd love for
glimpse()
to show colour the same way that tibbles do, to easily noticeNA
s etc. Currently it can be a bit hard to take in as an undifferentiated wall of text. Perhaps colouring the commas that separate the values in the same dim colour used for the column type would help too.The text was updated successfully, but these errors were encountered: