You can use switch to determine the behaviour based on the selection:
library(shiny)
myData <- runif(100)
plotType <- function(x, type) {
switch(type,
A = hist(x),
B = barplot(x),
C = pie(x))
}
runApp(list(
ui = bootstrapPage(
radioButtons("pType", "Choose plot type:",
list("A", "B", "C")),
plotOutput('plot')
),
server = function(input, output) {
output$plot <- renderPlot({
plotType(myData, input$pType)
})
}
))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…