Nothing
# Manual check: updateHierarchyInput() must update input$h without any click.
# Watch the R console; every button except "Expand"/"Open" must print a new value.
library(shiny)
library(shinyHierarchy)
df <- data.frame(
year = c(2026, 2026, 2026),
month = c("October", "October", "November"),
day = c(1, 2, 1)
)
df2 <- rbind(df, data.frame(year = 2026, month = "December", day = 1))
lv <- c("year", "month", "day")
ui <- fluidPage(
hierarchyInput("h", "Date", data = df, levels = lv,
selected = "2026::October"),
actionButton("data", "data + selected (December)"),
actionButton("sel", "selected only (November)"),
actionButton("clear", "clear = TRUE"),
actionButton("exp", "expanded only (no reprint)"),
actionButton("open", "open only (no reprint)")
)
server <- function(input, output, session) {
observe({
cat("\n--- input$h ---\n")
print(vapply(hierarchyResolved(input$h), function(n) n$id, ""))
})
observeEvent(input$data, updateHierarchyInput(
session, "h", data = df2, levels = lv, selected = "2026::December"
))
observeEvent(input$sel, updateHierarchyInput(
session, "h", selected = "2026::November"
))
observeEvent(input$clear, updateHierarchyInput(session, "h", clear = TRUE))
observeEvent(input$exp, updateHierarchyInput(
session, "h", expanded = "2026"
))
observeEvent(input$open, updateHierarchyInput(session, "h", open = TRUE))
}
shinyApp(ui, server)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.