在 R shiny returns 中使用 highchart 绘制两列缺少参数对象,没有任何值

Plotting two columns using highchart in R shiny returns argument object is missing with no value

我尝试使用 R shiny 制作交互式地图,它将显示某些城市的男性和女性公民的地块。数据框示例如下所示。

df1 <- read.table(header = TRUE, text = "city,year,male,female,long,lat
                  A,2017,1038,876,35.54331,139.12333
                  A,2018,1281,911,35.54331,139.12333
                  B,2017,832,517,35.14189,140.664113
                  B,2018,914,589,35.14189,140.664113", sep = ",")
df2 <- df1

交互式地图是使用leaflet包构建的,点击城市标记,会显示highchart构建的地块。

output$chart <- renderHighchart({

  df2 <- df1[df1$city == click_marker(),]
  hchart() %>%
    hc_add_series(df2, "column", hcaes(x = year, y = male, group = city, name = "Male")) %>%
    hc_add_series(df2, "column", hcaes(x = year, y = female, group = city, name = "Female")) %>%
    hc_xAxis(title = list(text = "Year")) %>%
    hc_yAxis(title = list(text = "Amount (Thousands)"))
})

highchartOutput('chart')

我希望输出是一个显示每年给定城市中男性和女性数量的图,但我得到的输出是 "argument object is missing, with no default."

如果将 hchart 更改为 highchart 并将名称更改为小写会怎么样?显然必须在 data.frame.

中找到它们
highchart() %>%
  hc_add_series(df2, "column", hcaes(x = year, y = male, group = city, name = "male")) %>%
  hc_add_series(df2, "column", hcaes(x = year, y = female, group = city, name = "female")) %>%
  hc_xAxis(title = list(text = "Year")) %>%
  hc_yAxis(title = list(text = "Amount (Thousands)"))