-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathtree-default.R
69 lines (62 loc) · 1.68 KB
/
tree-default.R
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
58
59
60
61
62
63
64
65
66
67
68
69
library(shiny)
library(shinyWidgets)
# data
cities <- data.frame(
continent = c("America", "America", "America", "Africa",
"Africa", "Africa", "Africa", "Africa",
"Europe", "Europe", "Europe", "Antarctica"),
country = c("Canada", "Canada", "USA", "Tunisia", "Tunisia",
"Tunisia", "Algeria", "Algeria", "Italy", "Germany", "Spain", NA),
city = c("Trois-Rivières", "Québec", "San Francisco", "Tunis",
"Monastir", "Sousse", "Alger", "Oran", "Rome", "Berlin", "Madrid", NA),
stringsAsFactors = FALSE
)
# app
ui <- fluidPage(
tags$h2("treeInput() example"),
fluidRow(
column(
width = 4,
treeInput(
inputId = "ID1",
label = "Select cities:",
choices = create_tree(cities),
selected = "San Francisco",
returnValue = "text",
closeDepth = 0
),
verbatimTextOutput("res1")
),
column(
width = 4,
treeInput(
inputId = "ID2",
label = "Select cities:",
choices = create_tree(cities),
selected = "San Francisco",
returnValue = "text",
closeDepth = 1
),
verbatimTextOutput("res2")
),
column(
width = 4,
treeInput(
inputId = "ID3",
label = "Select cities:",
choices = create_tree(cities),
selected = c("San Francisco", "Monastir"),
returnValue = "text",
closeDepth = 2
),
verbatimTextOutput("res3")
)
)
)
server <- function(input, output, session) {
output$res1 <- renderPrint(input$ID1)
output$res2 <- renderPrint(input$ID2)
output$res3 <- renderPrint(input$ID3)
}
if (interactive())
shinyApp(ui, server)