Skip to content

Instantly share code, notes, and snippets.

@MayaGans
Created February 10, 2020 22:37
Show Gist options
  • Save MayaGans/b74728ea83ec58ee0c5426f7b6b9ff66 to your computer and use it in GitHub Desktop.
Save MayaGans/b74728ea83ec58ee0c5426f7b6b9ff66 to your computer and use it in GitHub Desktop.
library(shiny)
library(tippy)
# list of dataframes
datalist <- list(data.frame(A = c("col_1", "col_2", "col_3"), B = c("val_1", "val_2", "val_3")),
data.frame(X = c("col_4", "col_5", "col_6"), Y = c("val_4", "val_5", "val_6")),
data.frame(A = c("col_7", "col_8", "col_9"), B = c("val_7", "val_8", "val_9")))
# named list
names(datalist) <- c("Group 1", "Group 2", "Group 3")
# Create function for single li
# name will be col_ and hover with be val_
rowBlock <- function(name, label) {
tags$li(tippy(div(name), label)
}
# Now give each dataframe in the list a title
# Using names(datalist)
# And loop through every row of every dataframe
# Is this two lapplys?
rowPallete <- function(data) {
div(h5(names(data),
lapply(data, rowBlock)
)
}
ui <-
# rowPalette(datafile)
# Should give me this:
div(
div(h1("Group 1"),
tags$li(tippy(div("col_1"), "val_1")),
tags$li(tippy(div("col_2"), "val_2")),
tags$li(tippy(div("col_3"), "val_3"))),
div(h1("Group 2"),
tags$li(tippy(div("col_4"), "val_4")),
tags$li(tippy(div("col_5"), "val_5")),
tags$li(tippy(div("col_6"), "val_6"))),
div(h1("Group 3"),
tags$li(tippy(div("col_7"), "val_7")),
tags$li(tippy(div("col_8"), "val_8")),
tags$li(tippy(div("col_9"), "val_9")))
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment