Home > Net >  R shinydashboard highcharter: arguments are not named in hc_add_series
R shinydashboard highcharter: arguments are not named in hc_add_series

Time:03-12

I'm trying to create a dashboard where a state can be selected and the graph is updated by that selection, but I get this error:

'Warning: Error in : 'df', 'hcaes(x = date, y = injured)' arguments are not named in hc_add_series [No stack trace available]'

library(tidyverse)
library(shiny)
library(shinydashboard)
library(highcharter)

ui <- dashboardPage(dashboardHeader(title = 'Test Dashboard'),
                    dashboardSidebar(),
                    dashboardBody(fluidPage(selectInput('select',
                                                        label = 'States',
                                                        choices = unique(opts),
                                                        selected = 'Alabama'),
                                            box(title = "Stock",
                                                status = "primary",
                                                solidHeader = TRUE,
                                                collapsible = TRUE,
                                                highchartOutput('plot')))))

server <- function(input,
                   output) {
  output$plot <- renderHighchart({
    df <- reactive({
      df <- massShooting2018.order %>%
        filter(state %in% input$select) %>%
        group_by(date) %>%
        summarise(
          dead = sum(dead),
          injured = (sum(injured)),
          total = sum(total)
        )
    })


    highchart(type = "stock") %>%
      hc_chart("line",
        name = "base",
        hcaes(x = date)
      ) %>%
      hc_add_series(df,
        name = "Total",
        type = "line",
        hcaes(
          x = date,
          y = total
        )
      ) %>%
      hc_add_series(df,
        name = "Dead",
        type = "line",
        hcaes(
          x = date,
          y = dead
        )
      ) %>%
      hc_add_series(df,
        name = "Injured",
        type = "line",
        hcaes(
          x = date,
          y = injured
        )
      ) %>%
      hc_tooltip(
        crosshairs = TRUE,
        shared = TRUE,
        borderWidth = 2,
        table = TRUE
      )
  })
}

shinyApp(ui, server)

enter image description here

  • Related