I am working with a tibble containing a column of xts as in the following example:
oneDf <- data.frame( name = "first", t = seq(now(),length=5,by = "days"), val = runif(5))
secDf <- data.frame( name = "sec",t = seq(now(),length=5,by = "days"), val = runif(5))
nested_data <- union(oneDf,secDf) %>%
group_by(name) %>%
nest() %>%
mutate(data = map(data, ~.x %>%
transmute(val, t) %>%
column_to_rownames("t") %>% as.xts()))
> nested_data
# A tibble: 2 × 2
# Groups: name [2]
name data
<chr> <list>
1 first <xts [5 × 1]>
2 sec <xts [5 × 1]>
The aim is to use hc_add_series_list to show the xts all named by the name-col. The preparation for hc_add_series (where the problem occurs) is as follows:
test <- nested_data %>%
group_by(name) %>%
do( ds = list( data = list_parse2(data.frame(row.names(.$data),coredata(.$data))))) %>%
{map2(.$name,.$ds, function(x,y){append(list(name=x),y)})}
...generates an Error due to the date-frame generation, so that I cannot use, as intended
highchart() %>%
hc_xAxis(type = "datetime") %>%
hc_add_series_list(test)
How do I have to change the data.frame(...) to get this to work? Thank you in advance,