rHighchart in R Shiny



我正试图在R中制作一个活跃的仪表板,我已经制作了一张美国犯罪地图:

highchart() %>%
hc_title(text = "Total crime in America") %>%
hc_subtitle(text = "Source: inkomen_crime.xlsx") %>%
hc_add_series_map(usgeojson, car,
name = "state",
value = "total_crime",
joinBy = c("woename", "state")) %>%
hc_mapNavigation(enabled = T)

然而,我似乎无法在R中运行它,代码是:

ui <- fluidPage(
selectInput(inputId = "stateDrop",
label = "Selecteer een Staat",
choices = all_states,
selected = "California",
multiple=TRUE),
DT::dataTableOutput(outputId = "America")
)
server <- function(input, output) {
output$America <- renderDataTable({
population <- data %>%
filter(State %in% input$stateDrop)
datatable(data = population)
})
}

我觉得我需要参考一下高点,但我在网上找不到任何东西。我做错了什么?请帮忙。

library(shiny)
library(highcharter)
library(tidyverse)
# Define UI for application 
ui <- fluidPage(
selectInput(inputId = "stateDrop",
label = "Selecteer een Staat",
choices = all_states,
selected = "California",
multiple=TRUE),
DT::dataTableOutput(outputId = "America"), 
highchartOutput(outputId = 'plot')
)
# Define server logic 
server <- function(input, output) {
output$America <- renderDataTable({
population <- data %>%
filter(State %in% input$stateDrop)
datatable(data = population)
})
output$plot <- renderHighchart({
highchart() %>%
hc_title(text = "Total crime in America") %>%
hc_subtitle(text = "Source: inkomen_crime.xlsx") %>%
hc_add_series_map(usgeojson, car,
name = "state",
value = "total_crime",
joinBy = c("woename", "state")) %>%
hc_mapNavigation(enabled = T)
})
}
# Run the application 
shinyApp(ui = ui, server = server)

最新更新