Description Usage Arguments Value Examples
View source: R/input-treeview.R
Create choice structure for treeviewInput
1 |
data |
A |
levels |
Variables identifying hierarchical levels. |
selected |
Default selected value(s). |
... |
Named arguments with |
a list
that can be used in treeviewInput
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | library(shinytreeview)
data("cities")
head(cities)
# Create choices that can be used in treeviewInput
make_tree(cities, c("continent", "country", "city"))
# Custom attributes for continent level
make_tree(cities, c("continent", "country", "city"), continent = list(selectable = FALSE))
library(shiny)
ui <- fluidPage(
tags$h3("treeviewInput cities example"),
fluidRow(
column(
width = 6,
treeviewInput(
inputId = "tree1",
label = "Choose an area:",
choices = make_tree(cities, c("continent", "country", "city")),
multiple = FALSE,
prevent_unselect = TRUE
),
verbatimTextOutput(outputId = "result1")
),
column(
width = 6,
treeviewInput(
inputId = "tree2",
label = "Choose an area (continent not selectable):",
choices = make_tree(
cities, c("continent", "country", "city"),
continent = list(selectable = FALSE)
),
multiple = FALSE,
prevent_unselect = TRUE
),
verbatimTextOutput(outputId = "result2")
)
)
)
server <- function(input, output, session) {
output$result1 <- renderPrint({
input$tree1
})
output$result2 <- renderPrint({
input$tree2
})
}
if (interactive())
shinyApp(ui, server)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.