I have my code written and i am trying to load a new graph based on radio button selection, however, the graph does not change. Only the first graph will load. I am having trouble figuring this out.
library(shiny)
library(r2d3)
library(shinythemes)
flare<-read.csv("flare.csv")
flare2<-read.csv("flare2.csv")
flare3<-read.csv("flare3.csv")
ui <- fluidPage(theme = shinytheme("darkly"),
headerPanel(title = "Radial Dendograph"),
sidebarLayout(
sidebarPanel(
radioButtons("choice","Desired Domain of Focus", choices = c("SI" = "SI","SA" =
"SA","NSSI" = "NSSI"))
),
mainPanel(
d3Output("d3"), width = 11
)
))
server <- function(input, output) {
dat<- reactive({
if (input$choice =="SI")
flare
else if (input$choice == "SA")
flare2
else if (input$choice == "NSSI")
flare3
})
output$d3 <- renderD3({
r2d3(data = dat(), d3_version = 5, script = "#1.js",css = "#2.css", dependencies = "d3-
jetpack")
})
}
#runs the app
shinyApp(ui = ui, server = server)