Data/reactives code updated
cmainov opened this issue · comments
Hey Jesse,
It turns out the solution to my problem was indeed harnessing a dataset in long format. This made reactive filtering quite easy to implement and I was able to streamline and minimize redundant code. I know you said you wanted to look at the code when it was updated and working. The relevant changes are in the "app.r" file and the data steps are in "09-Shapefiles-for-Shiny-App.R". The elements of the dashboard are currently functioning as intended in this version. My next step will be to incorporate the MSA plots, most likely in a separate tab.
Thanks
Chris
A couple of things:
I think you can define the reactive function outside of server. Think about it as your data filter step:
data_reactive <- reactive({
if (input$ptype=="dorling")
{ filter( cnties.dorling, year == input$yr_select ) }
if (input$ptype=="chloro") {
{ filter( cnties, year == input$yr_select ) }
} )
Makes the server code a lot cleaner:
# select plotting data
df.plot <- data_reactive()
# plot type
output$ptype <- renderPlot({ lp.plot.chloro( df = df.plot ) })
sounds good. I will update accordingly!
There's an extra { in the reactive function above, FYI. Just saw it.