如何使用nest()、map()和hchart()同时生成多个交互式图表?
我有一个数据集,基本上包含月份、星期几(星期一到星期日)、该月那一天发生的交通拥堵百分比。因此,我尝试使用 Nest()、map() 和 hchart() 创建一系列交互式饼图。但是,当我运行代码时,没有生成任何绘图,也没有错误消息。下面是我的代码。
by_Month_pie <- Jam_DofW_Month_Ratio %>%
group_by(Month) %>%
nest() %>%
mutate(plot = map(data,
~hchart(
'pie', hcaes(x= DofWeek, y=Ratio),
name = paste("Month: ", Jam_DofW_Month_Ratio$Month)) + # (.)
facet_grid(Month)))
by_Month_pie$plot
下面的代码可以很好地生成交互式饼图。
hc <- hchart(Jam_DofW_Month_Ratio %>%
subset(Jam_DofW_Month_Ratio$Month == 'a5'),
"pie", hcaes(x = DofWeek, y = Ratio),
name = paste("Month: ", Jam_DofW_Month_Ratio$Month)
)
hc
如果有朋友能帮我解决这个问题,我将不胜感激。多谢!
I have a dataset basically with the columns of Month, Day of Week (Monday to Sunday), the Percentage of Traffic Congestion happened on that Day in that Month. So, I was trying to create a series of interactive pie plots by using nest(), map() and hchart(). However, when I run the code, no plots were produced and there's no error messages. Below is my code.
by_Month_pie <- Jam_DofW_Month_Ratio %>%
group_by(Month) %>%
nest() %>%
mutate(plot = map(data,
~hchart(
'pie', hcaes(x= DofWeek, y=Ratio),
name = paste("Month: ", Jam_DofW_Month_Ratio$Month)) + # (.)
facet_grid(Month)))
by_Month_pie$plot
The code below works well to produce an interactive pie chart.
hc <- hchart(Jam_DofW_Month_Ratio %>%
subset(Jam_DofW_Month_Ratio$Month == 'a5'),
"pie", hcaes(x = DofWeek, y = Ratio),
name = paste("Month: ", Jam_DofW_Month_Ratio$Month)
)
hc
I would be really grateful if any friend could help me to work this problem out. Thanks a lot!
Table with each day's percentage of congestions for each month
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论