I am trying to use the new dygraphs for R library to plot winning times for men and women in the Boston Marathon each year. I've got a data frame of winning times by second, here's a portion of it:
winners <- data.frame(year=1966:1971, mensec=c(8231, 8145, 8537, 8029, 7830, 8325), womensec=c(12100, 12437, 12600, 12166, 11107, 11310))
But I don't know how to create an xts object from this. I can create a regular time series from each column and graph each one using dygraph in a separate graph
men <- ts(winners$mensec, frequency = 1, start=winners$year[1])
dygraph(men)
women <- ts(winners$womensec, frequency = 1, start=winners$year[1])
dygraph(women)
If I try to cbind the time series it won't work in dygraph
both <- cbind(men, women)
dygraph(both)
The error message is
Error in xts(x.mat, order.by = order.by, frequency = frequency(x), ...) : NROW(x) must match length(order.by)
Any suggestions? Thanks