-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.R
More file actions
64 lines (58 loc) · 1.61 KB
/
test.R
File metadata and controls
64 lines (58 loc) · 1.61 KB
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
library(shinydashboard)
library(shinydashboardPlus)
library(shiny)
shinyApp(
ui = dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(
minified = TRUE,
collapsed = TRUE,
sidebarMenu(
id = "sidebarMenu",
lapply(1:3, function(i) {
menuItem(
sprintf("Menu %s", i),
tabName = sprintf("menu_%s", i),
icon = icon("circle")
)
})
)
),
body = dashboardBody(
tabItems(
tabItem(tabName = "menu_1", "Content 1"),
tabItem(
tabName = "menu_2",
box(
title = "Always the same plot!",
collapsible = TRUE,
plotOutput("distPlot")
)
)
)
),
#controlbar = dashboardControlbar(),
title = "DashboardPage"
),
server = function(input, output, session) {
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
# Switch controlbar menu based on sidebar item value. Moreover
# if the sidebar menu item is 2, the controlbar opens
observeEvent(input$sidebarMenu, {
idx <- strsplit(input$sidebarMenu, "_")[[1]][2]
if (idx == 2) {
updateControlbar("controlbar")
}
updateControlbarMenu("controlbarMenu", selected = idx)
})
# Clicking on the second controlbar item makes the box sidebar open
observeEvent(input$controlbarMenu, {
if (input$controlbarMenu == "Tab 2") updateBoxSidebar("boxSidebar")
})
observeEvent(input$num, {
updateSliderInput(session, "obs", value = input$num)
}, ignoreInit = TRUE)
}
)