-
Notifications
You must be signed in to change notification settings - Fork 97
/
app.R
48 lines (42 loc) · 1.17 KB
/
app.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
library(shiny)
library(shiny.semantic)
ui <- semanticPage(
action_button("changetab", "Select First Tab!"),
br(),br(),
uiOutput("activetab"),
br(),br(),
selectInput(
inputId = "plot1xaxis",
label = "change x axis variable in third tab:",
choices = names(mtcars),
selected = "mpg",
width = 200
),
br(),br(),
tabset(
tabs = list(
list(menu = "First Tab", content = "Text works well", id = "first_tab"),
list(menu = "Second Tab", content = plotOutput("plot1"), id = "second_tab"),
list(menu = "Third Tab", content = plotOutput("plot2"))
),
active = "second_tab",
id = "exampletabset"
)
)
server <- function(input, output, session) {
observeEvent(input$changetab,{
update_tabset(session, "exampletabset", "first_tab")
})
output$plot1 <- renderPlot(
plot(c(1, 2), c(1, 5), type = 'b', main = "Plot 1",
xlab = "x axis", ylab = "y axis")
)
output$plot2 <- renderPlot(
plot(mtcars[[input$plot1xaxis]], mtcars$cyl, col = 'red',
xlab = input$plot1xaxis, ylab = "cyl")
)
output$activetab <- renderUI(
p(strong("Active Tab ID: "), input$exampletabset)
)
}
shiny::shinyApp(ui, server)