diff --git a/examples/zzz-grid-custom-header.R b/examples/zzz-grid-custom-header.R
index c4b1437..251e43d 100644
--- a/examples/zzz-grid-custom-header.R
+++ b/examples/zzz-grid-custom-header.R
@@ -57,14 +57,81 @@ datagrid(mtcars, theme = "striped", colwidths = "guess") %>%
)
-
-datagrid(ps3_games[, c(1, 5, 6, 7, 8)], colwidths = "guess", theme = "striped") %>%
+library(toastui)
+library(htmltools)
+# set_grid_theme(cell.summary.background = "#E6E7E7", cell.summary.showHorizontalBorder = TRUE)
+datagrid(ps3_games[, c(1, 3, 5, 6, 7, 8)], colwidths = "guess", theme = "striped") %>%
grid_summary(
column = "Name",
js_function = JS(
"function(value) {",
# "return \"character\";",
- sprintf("return '%scharacter';", gsub("\n", "", htmltools::doRenderTags(phosphoricons::ph("text-aa")))),
+ sprintf(
+ "return '%s';",
+ gsub(replacement = "", pattern = "\n", x = htmltools::doRenderTags(
+ tags$div(
+ style = css(padding = "5px 0"),
+ tags$div(
+ style = css(fontStyle = "italic"),
+ phosphoricons::ph("text-aa"),
+ "character"
+ ),
+ tags$hr(),
+ tags$div(
+ "Unique:", length(unique(ps3_games$Name))
+ ),
+ tags$div(
+ "Missing:", sum(is.na(ps3_games$Name))
+ ),
+ tags$div(
+ style = css(whiteSpace = "normal", wordBreak = "break-all"),
+ "Most Common:", gsub(
+ pattern = "'",
+ replacement = "\u07F4",
+ x = names(sort(table(ps3_games$Name), decreasing = TRUE))[1]
+ )
+ ),
+ tags$div(
+ "\u00A0"
+ )
+ )
+ ))
+ ),
+ "}"
+ ),
+ position = "top"
+ ) %>%
+ grid_summary(
+ column = "Genre",
+ js_function = JS(
+ "function(value) {",
+ # "return \"character\";",
+ sprintf(
+ "return '%s';",
+ gsub(replacement = "", pattern = "\n", x = htmltools::doRenderTags(
+ tags$div(
+ style = css(padding = "5px 0"),
+ tags$div(
+ style = css(fontStyle = "italic"),
+ phosphoricons::ph("text-aa"),
+ "character"
+ ),
+ tags$hr(),
+ tags$div(
+ "Unique:", length(unique(ps3_games$Genre))
+ ),
+ tags$div(
+ "Missing:", sum(is.na(ps3_games$Genre))
+ ),
+ tags$div(
+ "Most Common:", names(sort(table(ps3_games$Genre), decreasing = TRUE))[1]
+ ),
+ tags$div(
+ "\u00A0"
+ )
+ )
+ ))
+ ),
"}"
),
position = "top"
@@ -73,7 +140,32 @@ datagrid(ps3_games[, c(1, 5, 6, 7, 8)], colwidths = "guess", theme = "striped")
column = "NA_Sales",
js_function = JS(
"function(value) {",
- sprintf("return '%snumeric';", gsub("\n", "", htmltools::doRenderTags(phosphoricons::ph("hash")))),
+ sprintf(
+ "return '%s';",
+ gsub(replacement = "", pattern = "\n", x = htmltools::doRenderTags(
+ tags$div(
+ style = css(padding = "5px 0"),
+ tags$div(
+ style = css(fontStyle = "italic"),
+ phosphoricons::ph("hash"),
+ "numeric"
+ ),
+ tags$hr(),
+ tags$div(
+ "Min:", min(ps3_games$NA_Sales, na.rm = TRUE)
+ ),
+ tags$div(
+ "Mean:", mean(ps3_games$NA_Sales, na.rm = TRUE)
+ ),
+ tags$div(
+ "Max:", max(ps3_games$NA_Sales, na.rm = TRUE)
+ ),
+ tags$div(
+ "Missing:", sum(is.na(ps3_games$NA_Sales))
+ )
+ )
+ ))
+ ),
"}"
),
position = "top"