Time serie is a complex field of data visualisation. It consists to study the evolution of one or several variables through time, but time is a difficult format to work with. I strongly advise to use the lubridate library for the format management. Have a look to this section of the R for data science book, you won’t

regret it! If you need to draw a line plot, the dygraphs htmlwidget offers awesome possibilities as demonstrated below. It will be the main focus of this section. Ggplot2 and the tidyverse are really handy as well. Note that we sometimes will need to convert our data to the xts format using

the xts library. This sounds to be annoying at the beginning, but this format is really convenient if you have complex operation to compute, as shown at the end of this section. Last, the forecast library allows to … forecast data in a time series and a few examples are displayed below.




The dygraphs library

The dygraphs library is an html widget. It allows to make interactive time series chart: you can zoom and hover data points to get additional information. Start by reading the chart #316 for quick introduction and input description. Then, the graph #317 gives an overview of the different types of charts that are proposed. To go further, check the graph #318 (interactive version below) and the awesome Rstudio documentation.


Chart #318: interactive time series. (code here). This chart is interactive: zoom + hover + calculate rolling averages to better understand the data.




As usual, the tidyverse makes a really good work to handle time series. The lubridate library allows to easily manipulate the date format. Dplyr is really handy to re-arrange your data (aggregation, filtering..) and ggplot2 proposes some dedicated method to represent dates on your axis.



Other manipulation





Search the gallery