Accepted answer

a good approach to add multiples series in my opinion is use hc_add_series_list (oc you can use a for loop) which need a list of series (a series is for example list(name="a",data=mydata$a).

as you said, you need to melt/gather the data, you can use tidyr package:

mynewdata <- gather(mydata)

then you'll need to group the data by key argument to create the data for each key/series. here you can use dplyr package:

mynewdata2 <- mynewdata %>%
  # we change the key to name to have the label in the legend
  group_by(name = key) %>%  
  # the data in this case is simple, is just .$value column
  do(data = .$value) 

this data frame will contain two columns and the 2nd colum will contain the ten values for each row.

now you need this information in a list. so we need to parse using list.parse3 instad of list.parse2 beacuse preserve names like name or data.

series <- list.parse3(mynewdata2)

so finally change:




hope this is clear.

Related Query

More Query from same tag