How to compare and cluster sets of daily time series? I have multiple dataframes each representing traffic speed for each day of the year (366 dataframes for 366 days of the year). The raws of the dataframe are timestamp from 00:00 to 23:55 at 5 minute intervals and the columns are mileposts at 0.5 mile intervals and the entries are speed of traffic corresponding to the specific time and milepost. 
I want to group days of similar traffic conditions to examine daily traffic patterns/variations, which is standard for traffic analysis at a macro level, e.g., examining traffic patterns during weekdays and weekends.
To do this, I will have to measure similarity of the dataframes and apply clustering algorithms. Any idea on how to calculate similarity of dataframes and cluster them? Any R package that can do this?
Thanks
 A: Rather than look for a specialized similarity, you could represent the data in a way to use ordinary distance measures.  For instance, for each day, you could think of this a set of n time series (speed vs. time of day), one for each half mile marker. Then rearrange the day's data as one large vector (of size 288*n). Then you have one long vector for each day that you can analyze just like any other vector for pattern recognition, distance measures, clustering, etc.  You can use weighted Euclidean or any other ordinary distance measure. Then, you can process the days sequentially with a clustering technique suited for real time use.  Pictorially, if you have time series each day for 5 mile markers, the combination looks like:
 
You'd probably want to add an extra feature with values 1-7 for day of the week to each day's data, to account for the different conditions on weekends and nearby days, which should also aid in filtering out special events.   You could track changes over time continually updating the clustering each day.  
This approach to time series analysis was demonstrated for process control and estimation  &prediction at 
https://gregstanleyandassociates.com/whitepapers/BDAC/bdac.htm
and an associated paper that is in press.  
Efficient approaches to real-time clustering are discussed there also, in particular, RTEFC. 
