Search code examples
rplotgraphxtsdygraphs

R timeseries jumps and plotting in dygraph


I have a time series of stock data of several days, and big jumps in between the days as the data in the closing time of the stock market is missing of course.

Picture shows what I mean:

Graph

The time series used to plot is an xts object, which looks like this:

xts object

The graph is plotted using the following function:

  dygraph(stocks, main="Closing Stock Prices") %>%
  dyAxis("y", label="Value") %>%
  dySeries("..1",label="IBM") %>%
  dyOptions(colors = c("blue"), connectSeparatedPoints=TRUE) %>%
  dyRangeSelector()

Now what I really want is to "ignore" the value in between set dates and just plot the graph in one go without the gap between. Is this possible somehow?

I was thinking of just manipulating the time series and just consider as it single points as I don't necessarily need the time anyway but only the graph to be shown properly, but is this possible even as the xts object requires a time series object?!

Thanks in advance!!


Solution

  • Apparently there is no solution to hide it, other than going for NA values to hide the graph itself, but the gap which still exist.

    I now went for a generated timestamp misused as index to simulate the effect of an ongoing graph.