genres <- c("Pop", "Rap")
bins <- c(0, 10, 20, 50, 100, 200, 500, 1000, Inf)
pal <- colorBin("Greens", domain = c(0,2000), bins = bins)
ui <- dashboardPage(
skin = "green",
dashboardHeader(title = "Concert Ticket Prices Spotify & Seat Geek"),
dashboardSidebar(selectInput("genre", label = "Genre",choices = genres, selected = "Rap")),
dashboardBody(
fluidRow(box(width = 12,leafletOutput(outputId = "mymap"))),
downloadButton('downloadData', 'Download Data Set (CSV)'),
fluidRow(box(width = 12, dataTableOutput(outputId = "summary_table"))),
fluidRow(textOutput(outputId = "n1")),
)
)
server <- function(input, output, session){
text <- reactive({input$genre})
text2 <- reactive({text()})
genre_shp <- Allgenre[Allgenre$genre == text2,]
labels <- sprintf(
"<strong>%s</strong><br/>Average Price: $%g <br/>%s </br> %s, %s <br/> %s ",
genre_shp$Artist, genre_shp$`Avg Price`, genre_shp$Venue, genre_shp$City, genre_shp$name, genre_shp$`Data & Time`
) %>% lapply(htmltools::HTML)
output$mymap <- renderLeaflet(
leaflet(genre_shp) %>%
setView(-96, 37.8, 4) %>%
addProviderTiles("MapBox", options = providerTileOptions(
id = "mapbox.light",
accessToken = Sys.getenv('MAPBOX_ACCESS_TOKEN'))) %>%
addPolygons(
fillColor = ~pal(genre_shp$`Avg Price`),
weight = 2,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlight = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%
addLegend(pal = pal,
values = genre_shp$`Avg Price`, opacity = 0.7, title = NULL,
position = "bottomright")
)
genres <- c("Pop", "Rap")
bins <- c(0, 10, 20, 50, 100, 200, 500, 1000, Inf)
pal <- colorBin("Greens", domain = c(0,2000), bins = bins)
ui <- dashboardPage(
skin = "green",
dashboardHeader(title = "Concert Ticket Prices Spotify & Seat Geek"),
dashboardSidebar(selectInput("genre", label = "Genre",choices = genres, selected = "Rap")),
dashboardBody(
fluidRow(box(width = 12,leafletOutput(outputId = "mymap"))),
downloadButton('downloadData', 'Download Data Set (CSV)'),
fluidRow(box(width = 12, dataTableOutput(outputId = "summary_table"))),
fluidRow(textOutput(outputId = "n1")),
)
)
server <- function(input, output, session){
text <- reactive({input$genre})
text2 <- reactive({text()})
genre_shp <- Allgenre[Allgenre$genre == text2,]
labels <- sprintf(
"<strong>%s</strong><br/>Average Price: $%g <br/>%s </br> %s, %s <br/> %s ",
genre_shp$Artist, genre_shp$`Avg Price`, genre_shp$Venue, genre_shp$City, genre_shp$name, genre_shp$`Data & Time`
) %>% lapply(htmltools::HTML)
output$mymap <- renderLeaflet(
leaflet(genre_shp) %>%
setView(-96, 37.8, 4) %>%
addProviderTiles("MapBox", options = providerTileOptions(
id = "mapbox.light",
accessToken = Sys.getenv('MAPBOX_ACCESS_TOKEN'))) %>%
addPolygons(
fillColor = ~pal(genre_shp$`Avg Price`),
weight = 2,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlight = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto")) %>%
addLegend(pal = pal,
values = genre_shp$`Avg Price`, opacity = 0.7, title = NULL,
position = "bottomright")
)
output$summary_table <- renderDataTable(data.frame(genre_shp))
output$downloadData <- downloadHandler(
filename = function() {
paste('SelectedRows', '.csv', sep='')
},
content = function(file) {
write.csv(genre_shp, file)
}
)
}
shinyApp(ui=ui, server = server)
Allgenre is not defined.
library(shiny)
library(shinydashboard)
library(leaflet)
genres <- c("Pop", "Rap")
bins <- c(0, 10, 20, 50, 100, 200, 500, 1000, Inf)
pal <- colorBin("Greens", domain = c(0, 2000), bins = bins)
ui <- dashboardPage(
skin = "green",
dashboardHeader(title = "Concert Ticket Prices Spotify & Seat Geek"),
dashboardSidebar(selectInput("genre", label = "Genre", choices = genres, selected = "Rap")),
dashboardBody(
fluidRow(box(width = 12, leafletOutput(outputId = "mymap"))),
downloadButton("downloadData", "Download Data Set (CSV)"),
fluidRow(box(width = 12, dataTableOutput(outputId = "summary_table"))),
fluidRow(textOutput(outputId = "n1")),
)
)
server <- function(input, output, session) {
genre_shp <- reactive({
req(input$genre)
Allgenre[Allgenre$genre == input$genre, ]
})
output$mymap <- renderLeaflet({
labels <- sprintf(
"<strong>%s</strong><br/>Average Price: $%g <br/>%s </br> %s, %s <br/> %s ",
genre_shp()$Artist, genre_shp()$`Avg Price`, genre_shp()$Venue, genre_shp()$City, genre_shp()$name, genre_shp()$`Data & Time`
) %>% lapply(htmltools::HTML)
leaflet(genre_shp()) %>%
setView(-96, 37.8, 4) %>%
addProviderTiles("MapBox", options = providerTileOptions(
id = "mapbox.light",
accessToken = Sys.getenv("MAPBOX_ACCESS_TOKEN")
)) %>%
addPolygons(
fillColor = ~ pal(genre_shp()$`Avg Price`),
weight = 2,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7,
highlight = highlightOptions(
weight = 5,
color = "#666",
dashArray = "",
fillOpacity = 0.7,
bringToFront = TRUE
),
label = labels,
labelOptions = labelOptions(
style = list("font-weight" = "normal", padding = "3px 8px"),
textsize = "15px",
direction = "auto"
)
) %>%
addLegend(
pal = pal,
values = genre_shp()$`Avg Price`, opacity = 0.7, title = NULL,
position = "bottomright"
)
})
output$summary_table <- renderDataTable(genre_shp())
output$downloadData <- downloadHandler(
filename = function() {
paste("SelectedRows", ".csv", sep = "")
},
content = function(file) {
write.csv(genre_shp(), file)
}
)
}
shinyApp(ui = ui, server = server)
This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.