Accepted answer

would first convert your data frame to long. then you can group_by category and use list_parse2 to make lists by category.

for this plot, i made sure month was numeric on x-axis. i renamed category to name so it would show up in legend and labels. and added connectnulls in case you wanted to connect points across missing values (na).


reprexdf2 <- reprexdf %>%
  pivot_longer(cols = -category, names_to = "month", values_to = "value", names_pattern = "month(\\d)$") %>%
  group_by(category) %>%
  do(data = list_parse2(data.frame(as.numeric(.$month), .$value))) %>%
  ungroup() %>%
  rename(name = category)

highchart() %>%
  hc_plotoptions(series = list(connectnulls = true), line = list(marker = list(enabled = false)))%>%

highcharter with lines

Related Query

More Query from same tag