DfT traffic count data in R

January 26, 2018
By

(This article was first published on R – scottishsnow, and kindly contributed to R-bloggers)

I read this tweet thread yesterday, and one of the great things in it was discovering that the Department for Transport release traffic count data for Great Britain.

When you download individual observation locations you get a csv with a few years data. I checked out the one for a street near where I live using R (code at the bottom of this post):

The_Loan

Traffic count data for The Loan, Loanhead. Note the y scales vary with each plot.

The obvious thing to notice is the large jump in 2010. The data download also includes meta data for each year. Count observations were made in 2001 and in 2010 and all other years are estimated. I don’t know what the count frequency is in surrounding areas, but I can imagine infilling missing data is hard. However, it does look like the DfT model could do with some work, based on this anecdote ?

Following download, the above plot was made using the following 10 lines of R code:

library(tidyr)
library(dplyr)
library(ggplot2)

x = read.csv("~/Downloads/80158.csv")

x %>%
   select(AADFYear, PedalCycles, Motorcycles, CarsTaxis, BusesCoaches, LightGoodsVehicles, AllHGVs) %>%
   gather(Vehicle, Count, -AADFYear) %>%
   ggplot(aes(AADFYear, Count)) +
   geom_point() +
   facet_wrap(~Vehicle, scales="free_y")

To leave a comment for the author, please follow the link and comment on their blog: R – scottishsnow.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)