I\'m trying to create a Shiny
App. The user interface UI.R
looks just fine but I\'m having issues with server.R
. Basically I want a di
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)
})
}
))