0

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

Zizhao He
  • 23
  • 2
  • Welcome to SO! To help us to help you would you mind sharing [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. – stefan Feb 23 '22 at 22:05
  • This said: You do not pass any data to `hchart`. Try with `~ hchart(.x, ....)`. Also, as you are using `highcharter` what are your trying to achieve with `+ facet_grid(..)` which is `ggplot2`? – stefan Feb 23 '22 at 22:07
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 24 '22 at 10:50

0 Answers0