Tabsets

Tabsets
한 화면에 탭을 만들어 탭별로 다른 그래프나 테이블을 출력할 수 있다.
tabsetPanel(... ,id=NULL, selected=NULL)
tabPanel(title, ..., value=NULL)
radioButtons(inputid, label, choices, selected=NULL)
ui.R(Tabsets)
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Tabsets"),
sidebarPanel(
radioButtons("dist", "Distribution type: ", list("Normal"="norm", "Uniform"="unif", "Log-normal"="lnorm", "Exponential"="exp")),
br(),
sliderInput("n", "Number of observations: ", value=500, min=1, max=1000)
),
mainPanel(
tabsetPanel(
tabPanel("Plot", plotOutput("plot")),
tabPanel("Summary", verbatimTextOutput("summary")),
tabPanel("Table", tableOutput("table"))
)
)
))
server.R(Tabsets)
library(shiny)
shinyServer(function(input, output){
data<-reactive({
dist<-switch(input$dist, norm=rnorm, unif=runif, lnorm=rlnorm, exp=rexp, rnorm)
dist(input$n)
})
output$plot<-renderPlot({
dist<-input$dist
n<-input$n
hist(data(), main=paste("r", dist, "(", n, ")", sep=""))
})
output$summary<-renderPrint({
summary(data())
})
output$table<-renderTable({
data.frame(x=data())
})
})