GeneratePercentiles: Estimate Speed Percentiles for Traffic Count Data

Description Usage Arguments Value Author(s) Examples

View source: R/secondaryscripts.R


Motorway Incident Detection and Automatic Signalling (MIDAS) is a sensor based network along UK motorways, and is designed to collect data regarding traffic flows, average speeds and road occupancy, amongst other features, on the road network. This data can be accessed via the MIDAS website (login required) in the form of .tcd.bz2 files.

The function GeneratePercentiles provides the user with an estimated nth percentile speed, (the speed that n% of the drivers within a given time period drive at or below) based on the data collected in the RoadData.

Please note that this function only provides an estimate of the percentile speeds, due to the nature of the MIDAS data. It should be acknowledged that the results from this function may not be representative of the true percentile speeds.


GeneratePercentiles(data, percentile, timeInterval)



The data that the user wishes to investigate.


Numeric; the percentile of drivers that travel under a particular speed (a value commonly investigated 85%; that is, the function will find out the speed at which 85 of drivers travel at or below).


Numeric; the MIDAS data does not provide accurate details regarding the speed of every vehicle travelling, only the average speed and the number of vehicles passing a MIDAS site per minute. The function therefore assumes that all vehicles in a minute travel at the same average speed, and so to calculate a percentile speed, a sample must be selected over a period of time. This argument is that period of time, in minutes. This time interval must divide the number of rows in the data dataframe.


A version of the format of data, where additional data has been added in the form of a column at the end of the data, denoting the percentile speed. Please note that all rows that are in the same time interval share the same value in this column. For example, if 60 minute samples are taken, then the first 60 rows will share the same value, followed by the second 60 rows, and so on.


RAC Foundation, Luke Hudlass-Galley


dataWithHourly85Percentiles <- GeneratePercentiles(roadData, 85, 60)

RACFoundation/oneminutetrafficdata documentation built on Dec. 2, 2018, 1:14 p.m.