I am using ggplot to plot chloropleth maps of the UK based on investment from US to UK. This can be catagorised by either 'Projects', 'Avg Capex' or 'Jobs'. I want to fill the map with colour depending on which of the 3 previous variables is selected.
At the moment my app is only displaying a uniform colour regardless of which option I press. The code works when not in shiny but I can't get it to work in shiny!
My code for the UI and server
ui <- fluidPage(
titlePanel("North America Investment 2019"),
selectInput(inputId = "group_select", label = "Investment Measure",
choices = colnames(together)[c(8,10,11)], selected = colnames(together)[8]),
plotOutput('plot')
)
server <- function(input, output) {
g <- ggplot(together, aes(x = long, y = lat, group = group), col = "black") +
geom_polygon(aes(fill = input$group_select))
output$plot <- renderPlot(g)
}
shinyApp(ui = ui, server = server)
where my colnames(togther) are
[1] "long" "lat" "order" "hole" "piece"
[6] "group" "id" "Projects" "Capex" "Avg capex"
[11] "Jobs created" "Avg jobs" "Companies"
This is my first time using RShiny