使用r-highcharter库深入查看分组柱形图

时间:2017-05-22 10:25:21

标签: r highcharts r-highcharter

我正在努力在使用highcharter制作的分组柱形图中添加一级钻取。为了解释,我正在使用highcharter库中提供的“疫苗”数据集:

创建分组柱形图的代码(类似):

library (highcharter)
library(dplyr)

df <- na.omit(vaccines[vaccines$year %in% c("1928", "1929"),])
df <- ddply(df, c("state", "year"), summarise, count = sum(count))
hc <- hchart(df, type = "column", hcaes(x = state, y = count, group = year)) %>% 
  hc_xAxis(title = list(text = "States")) %>% 
  hc_yAxis(title = list(text = "Vaccines")) %>% 
  hc_chart(type = "Vaccines", options3d = list(enabled = TRUE, beta = 0, alpha = 0)) %>% 
  hc_title(text = "Demo Example") %>% 
  hc_subtitle(text = "Click on the on Year to see the Vaccine drill down")
hc

它完美地创建了这个分组图表 It creates this grouped chart perfectly

我现在想在图表中添加一个级别的钻取,我可以选择“年份”,并显示所选疫苗的相应深入数据。考虑到我在数据框中也有单独的向下钻取数据,您能否请用最好/最简单的方法来帮助它。

此致 NIKHIL

0 个答案:

没有答案