Carlsbad-Blvd

setwd("C:/Users/s-das/Syncplicity Folders/MY_Projects/NCHRP 17-76/04102017/Data Sources/INRIX/")
a01 <- read.csv("C/Carlsbad-Blvd-entire-length-9-11-16.csv")
str(a01)
## 'data.frame':    108864 obs. of  9 variables:
##  $ tmc_code           : Factor w/ 54 levels "106-13652","106-13653",..: 3 41 49 10 45 40 27 47 36 42 ...
##  $ measurement_tstamp : Factor w/ 2016 levels "9/11/2016 0:00",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ speed              : num  21 25 22 30 22 35 32 44 40 33 ...
##  $ average_speed      : int  21 25 22 30 22 35 32 44 40 33 ...
##  $ reference_speed    : int  20 22 16 29 31 31 32 40 36 34 ...
##  $ travel_time_minutes: num  1.3 0.04 0.04 1.6 0.13 0.01 3.74 0.28 0.5 0.03 ...
##  $ confidence_score   : num  20 20 20 20 20 20 20 20 20 20 ...
##  $ cvalue             : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ tmc1               : Factor w/ 54 levels "TMC106-13652",..: 3 41 49 10 45 40 27 47 36 42 ...
a02 <- read.csv("C/TMC_Identification1.csv")
a03 <- merge(a01, a02, by="tmc1")
dim(a01)
## [1] 108864      9
dim(a02)
## [1] 54 14
dim(a03)
## [1] 108864     22
names(a03)
##  [1] "tmc1"                "tmc_code"            "measurement_tstamp" 
##  [4] "speed"               "average_speed"       "reference_speed"    
##  [7] "travel_time_minutes" "confidence_score"    "cvalue"             
## [10] "tmc"                 "road"                "direction"          
## [13] "intersection"        "state"               "county"             
## [16] "zip"                 "start_latitude"      "start_longitude"    
## [19] "end_latitude"        "end_longitude"       "miles"              
## [22] "road_order"
table(a03$direction)
## 
## NORTHBOUND SOUTHBOUND 
##      54432      54432
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
a03$Time <- format(as.POSIXct(strptime(a03$measurement_tstamp, "%m/%d/%Y  %H:%M",tz="")) ,format = "%H:%M")
a03$Time1 <- as.POSIXct(a03$Time, format = "%H:%M")
a03$Date <- format(as.POSIXct(strptime(a03$measurement_tstamp, "%m/%d/%Y  %H:%M",tz="")) ,format = "%Y-%m-%d")
a03$Time1 <- as.POSIXct(a03$Time, format = "%H:%M")
a03$Date1 <- as.Date(a03$Date)
a03$Day <- wday(a03$Date1, label = TRUE)
str(a03)
## 'data.frame':    108864 obs. of  27 variables:
##  $ tmc1               : Factor w/ 54 levels "TMC106-13652",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ tmc_code           : Factor w/ 54 levels "106-13652","106-13653",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ measurement_tstamp : Factor w/ 2016 levels "9/11/2016 0:00",..: 1515 1238 1355 1036 1893 371 1257 18 45 1460 ...
##  $ speed              : num  14 24.2 27 27.2 27 ...
##  $ average_speed      : int  21 21 27 28 26 24 22 28 22 25 ...
##  $ reference_speed    : int  28 28 28 28 28 28 28 28 28 28 ...
##  $ travel_time_minutes: num  4.17 2.42 2.16 2.15 2.16 2.26 2.65 2.08 2.94 2.33 ...
##  $ confidence_score   : num  30 30 20 28 30 30 20 20 30 20 ...
##  $ cvalue             : num  63.4 100 0 80 100 100 0 0 100 0 ...
##  $ tmc                : Factor w/ 54 levels "106-13652","106-13653",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ road               : Factor w/ 1 level "CR-S21": 1 1 1 1 1 1 1 1 1 1 ...
##  $ direction          : Factor w/ 2 levels "NORTHBOUND","SOUTHBOUND": 2 2 2 2 2 2 2 2 2 2 ...
##  $ intersection       : Factor w/ 18 levels "4TH ST/DEL MAR HEIGHTS RD",..: 17 17 17 17 17 17 17 17 17 17 ...
##  $ state              : Factor w/ 1 level "CA": 1 1 1 1 1 1 1 1 1 1 ...
##  $ county             : Factor w/ 1 level "SAN DIEGO": 1 1 1 1 1 1 1 1 1 1 ...
##  $ zip                : int  92054 92054 92054 92054 92054 92054 92054 92054 92054 92054 ...
##  $ start_latitude     : num  33.2 33.2 33.2 33.2 33.2 ...
##  $ start_longitude    : num  -117 -117 -117 -117 -117 ...
##  $ end_latitude       : num  33.2 33.2 33.2 33.2 33.2 ...
##  $ end_longitude      : num  -117 -117 -117 -117 -117 ...
##  $ miles              : num  0.973 0.973 0.973 0.973 0.973 ...
##  $ road_order         : num  7 7 7 7 7 7 7 7 7 7 ...
##  $ Time               : chr  "14:10" "15:05" "23:50" "21:15" ...
##  $ Time1              : POSIXct, format: "2017-04-13 14:10:00" "2017-04-13 15:05:00" ...
##  $ Date               : chr  "2016-09-16" "2016-09-15" "2016-09-15" "2016-09-14" ...
##  $ Date1              : Date, format: "2016-09-16" "2016-09-15" ...
##  $ Day                : Ord.factor w/ 7 levels "Sun"<"Mon"<"Tues"<..: 6 5 5 4 7 2 5 1 1 6 ...
aa1 <- subset(a03, direction=="NORTHBOUND")
aa3 <- subset(a03, direction=="SOUTHBOUND")
require(ggplot2)
## Loading required package: ggplot2
require(scales)
## Loading required package: scales
ggplot(aa1, aes(x=Time1, y=speed)) + 
  geom_point(size=.9, alpha = 0.05, colour="green") + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M"))+theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Carlsbad Blvd (Northbound)")

ggplot(aa1, aes(x=Time1, y=speed, colour=Day)) + 
  geom_point(size=.5, alpha = 0.1) + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M")) +
  facet_grid(Day ~.) +
  theme(legend.position="none") +theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Carlsbad Blvd (Northbound)")

ggplot(aa3, aes(x=Time1, y=speed)) + 
  geom_point(size=.9, alpha = 0.05, colour="green") + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M"))+theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Carlsbad Blvd (Southbound)")

ggplot(aa3, aes(x=Time1, y=speed, colour=Day)) + 
  geom_point(size=.5, alpha = 0.1) + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M")) +
  facet_grid(Day ~.) +
  theme(legend.position="none") +theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Carlsbad Blvd (Southbound)")

aa2 <- aggregate(speed ~ Time1+direction+Day, a03, mean)
head(aa2)
##                 Time1  direction Day    speed
## 1 2017-04-13 00:00:00 NORTHBOUND Sun 31.36963
## 2 2017-04-13 00:05:00 NORTHBOUND Sun 31.30259
## 3 2017-04-13 00:10:00 NORTHBOUND Sun 31.27370
## 4 2017-04-13 00:15:00 NORTHBOUND Sun 31.31037
## 5 2017-04-13 00:20:00 NORTHBOUND Sun 31.44444
## 6 2017-04-13 00:25:00 NORTHBOUND Sun 31.37481
dim(aa1)
## [1] 54432    27
dim(aa2)
## [1] 4032    4
colnames(aa2)[2] <- "Direction"
ggplot(aa2, aes(x=Time1, y=speed, colour=Direction)) + 
  geom_path() + geom_point(cex=0.4)+
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M")) +
  facet_grid(Day ~.) +
  theme(legend.position="none") +theme_bw()+labs(x="Time of Day", y="Speed (mph)")

Kearny-Villa-Rd

setwd("C:/Users/s-das/Syncplicity Folders/MY_Projects/NCHRP 17-76/04102017/Data Sources/INRIX/")
a01 <- read.csv("K/Kearny-Villa-Rd-entire-length-9-11-16.csv")
str(a01)
## 'data.frame':    64512 obs. of  9 variables:
##  $ tmc_code           : Factor w/ 32 levels "106-11852","106-11853",..: 11 5 20 30 26 12 14 1 16 18 ...
##  $ measurement_tstamp : Factor w/ 2016 levels "9/11/2016 0:00",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ speed              : num  25 56 35 56 28 52 61 32 21 29 ...
##  $ average_speed      : int  25 56 35 56 28 52 61 38 21 29 ...
##  $ reference_speed    : int  27 56 33 57 22 47 59 34 21 23 ...
##  $ travel_time_minutes: num  2.49 0.08 0.27 0.45 0.56 0.95 0.91 2.26 1.1 0.55 ...
##  $ confidence_score   : num  20 20 20 20 20 20 20 30 20 20 ...
##  $ cvalue             : num  0 0 0 0 0 0 0 100 0 0 ...
##  $ tmc1               : Factor w/ 32 levels "TMC106-11852",..: 11 5 20 30 26 12 14 1 16 18 ...
a02 <- read.csv("K/TMC_Identification2.csv")
a03 <- merge(a01, a02, by="tmc1")
dim(a01)
## [1] 64512     9
dim(a02)
## [1] 32 14
dim(a03)
## [1] 64512    22
names(a03)
##  [1] "tmc1"                "tmc_code"            "measurement_tstamp" 
##  [4] "speed"               "average_speed"       "reference_speed"    
##  [7] "travel_time_minutes" "confidence_score"    "cvalue"             
## [10] "tmc"                 "road"                "direction"          
## [13] "intersection"        "state"               "county"             
## [16] "zip"                 "start_latitude"      "start_longitude"    
## [19] "end_latitude"        "end_longitude"       "miles"              
## [22] "road_order"
table(a03$direction)
## 
## NORTHBOUND SOUTHBOUND 
##      32256      32256
library(lubridate)
a03$Time <- format(as.POSIXct(strptime(a03$measurement_tstamp, "%m/%d/%Y  %H:%M",tz="")) ,format = "%H:%M")
a03$Time1 <- as.POSIXct(a03$Time, format = "%H:%M")
a03$Date <- format(as.POSIXct(strptime(a03$measurement_tstamp, "%m/%d/%Y  %H:%M",tz="")) ,format = "%Y-%m-%d")
a03$Time1 <- as.POSIXct(a03$Time, format = "%H:%M")
a03$Date1 <- as.Date(a03$Date)
a03$Day <- wday(a03$Date1, label = TRUE)
str(a03)
## 'data.frame':    64512 obs. of  27 variables:
##  $ tmc1               : Factor w/ 32 levels "TMC106-11852",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ tmc_code           : Factor w/ 32 levels "106-11852","106-11853",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ measurement_tstamp : Factor w/ 2016 levels "9/11/2016 0:00",..: 920 1988 1606 1562 1405 1442 1482 478 1257 550 ...
##  $ speed              : num  35 26 37 25.6 33 ...
##  $ average_speed      : int  31 32 37 32 33 36 33 34 29 30 ...
##  $ reference_speed    : int  34 34 34 34 34 34 34 34 34 34 ...
##  $ travel_time_minutes: num  2.06 2.78 1.95 2.82 2.19 2.01 2.46 2.19 3.04 2.93 ...
##  $ confidence_score   : num  30 30 20 30 20 20 30 30 30 30 ...
##  $ cvalue             : num  100 100 0 100 0 0 100 97.2 100 100 ...
##  $ tmc                : Factor w/ 32 levels "106-11852","106-11853",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ road               : Factor w/ 1 level "KEARNY VILLA RD": 1 1 1 1 1 1 1 1 1 1 ...
##  $ direction          : Factor w/ 2 levels "NORTHBOUND","SOUTHBOUND": 2 2 2 2 2 2 2 2 2 2 ...
##  $ intersection       : Factor w/ 9 levels "CA-163","CA-274/BALBOA AVE",..: 7 7 7 7 7 7 7 7 7 7 ...
##  $ state              : Factor w/ 1 level "CA": 1 1 1 1 1 1 1 1 1 1 ...
##  $ county             : Factor w/ 1 level "SAN DIEGO": 1 1 1 1 1 1 1 1 1 1 ...
##  $ zip                : int  92123 92123 92123 92123 92123 92123 92123 92123 92123 92123 ...
##  $ start_latitude     : num  32.8 32.8 32.8 32.8 32.8 ...
##  $ start_longitude    : num  -117 -117 -117 -117 -117 ...
##  $ end_latitude       : num  32.8 32.8 32.8 32.8 32.8 ...
##  $ end_longitude      : num  -117 -117 -117 -117 -117 ...
##  $ miles              : num  1.2 1.2 1.2 1.2 1.2 ...
##  $ road_order         : int  15 15 15 15 15 15 15 15 15 15 ...
##  $ Time               : chr  "12:35" "07:35" "20:45" "18:05" ...
##  $ Time1              : POSIXct, format: "2017-04-13 12:35:00" "2017-04-13 07:35:00" ...
##  $ Date               : chr  "2016-09-14" "2016-09-17" "2016-09-16" "2016-09-16" ...
##  $ Date1              : Date, format: "2016-09-14" "2016-09-17" ...
##  $ Day                : Ord.factor w/ 7 levels "Sun"<"Mon"<"Tues"<..: 4 7 6 6 5 6 6 2 5 2 ...
aa1 <- subset(a03, direction=="NORTHBOUND")
aa3 <- subset(a03, direction=="SOUTHBOUND")
require(ggplot2)
require(scales)

ggplot(aa1, aes(x=Time1, y=speed)) + 
  geom_point(size=.9, alpha = 0.05, colour="green") + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M"))+theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Kearny Villa Rd (Northbound)")

ggplot(aa1, aes(x=Time1, y=speed, colour=Day)) + 
  geom_point(size=.5, alpha = 0.1) + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M")) +
  facet_grid(Day ~.) +
  theme(legend.position="none") +theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Kearny Villa Rd (Northbound)")

ggplot(aa3, aes(x=Time1, y=speed)) + 
  geom_point(size=.9, alpha = 0.05, colour="green") + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M"))+theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Kearny Villa Rd (Southbound)")

ggplot(aa3, aes(x=Time1, y=speed, colour=Day)) + 
  geom_point(size=.5, alpha = 0.1) + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M")) +
  facet_grid(Day ~.) +
  theme(legend.position="none") +theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Kearny Villa Rd (Southbound)")

aa2 <- aggregate(speed ~ Time1+direction+Day, a03, mean)
head(aa2)
##                 Time1  direction Day speed
## 1 2017-04-13 00:00:00 NORTHBOUND Sun 36.75
## 2 2017-04-13 00:05:00 NORTHBOUND Sun 36.75
## 3 2017-04-13 00:10:00 NORTHBOUND Sun 36.75
## 4 2017-04-13 00:15:00 NORTHBOUND Sun 36.75
## 5 2017-04-13 00:20:00 NORTHBOUND Sun 36.75
## 6 2017-04-13 00:25:00 NORTHBOUND Sun 36.75
dim(aa1)
## [1] 32256    27
dim(aa2)
## [1] 4032    4
colnames(aa2)[2] <- "Direction"
ggplot(aa2, aes(x=Time1, y=speed, colour=Direction)) + 
  geom_path() + geom_point(cex=0.4)+
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M")) +
  facet_grid(Day ~.) +
  theme(legend.position="none") +theme_bw()+labs(x="Time of Day", y="Speed (mph)")

Nimitz-Blvd

setwd("C:/Users/s-das/Syncplicity Folders/MY_Projects/NCHRP 17-76/04102017/Data Sources/INRIX/")
a01 <- read.csv("N/Nimitz-Blvd-entire-length-9-11-16.csv")
str(a01)
## 'data.frame':    32256 obs. of  9 variables:
##  $ tmc_code           : Factor w/ 16 levels "106-14016","106-14017",..: 16 7 13 4 9 1 2 3 5 14 ...
##  $ measurement_tstamp : Factor w/ 2016 levels "9/11/2016 0:00",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ speed              : num  19 36.1 36 29 9 ...
##  $ average_speed      : int  19 35 36 22 9 24 31 38 27 12 ...
##  $ reference_speed    : int  18 40 36 19 13 24 29 37 25 14 ...
##  $ travel_time_minutes: num  0.28 1.54 0.01 0.44 0.06 0.8 1.31 1.45 0.72 0.04 ...
##  $ confidence_score   : num  20 22 10 30 20 20 20 30 20 20 ...
##  $ cvalue             : num  0 19.2 0 22.6 0 0 0 95.8 0 0 ...
##  $ tmc1               : Factor w/ 16 levels "TMC106-14016",..: 16 7 13 4 9 1 2 3 5 14 ...
a02 <- read.csv("N/TMC_Identification3.csv")
a03 <- merge(a01, a02, by="tmc1")
dim(a01)
## [1] 32256     9
dim(a02)
## [1] 16 14
dim(a03)
## [1] 32256    22
names(a03)
##  [1] "tmc1"                "tmc_code"            "measurement_tstamp" 
##  [4] "speed"               "average_speed"       "reference_speed"    
##  [7] "travel_time_minutes" "confidence_score"    "cvalue"             
## [10] "tmc"                 "road"                "direction"          
## [13] "intersection"        "state"               "county"             
## [16] "zip"                 "start_latitude"      "start_longitude"    
## [19] "end_latitude"        "end_longitude"       "miles"              
## [22] "road_order"
table(a03$direction)
## 
## NORTHBOUND SOUTHBOUND 
##      16128      16128
library(lubridate)
a03$Time <- format(as.POSIXct(strptime(a03$measurement_tstamp, "%m/%d/%Y  %H:%M",tz="")) ,format = "%H:%M")
a03$Time1 <- as.POSIXct(a03$Time, format = "%H:%M")
a03$Date <- format(as.POSIXct(strptime(a03$measurement_tstamp, "%m/%d/%Y  %H:%M",tz="")) ,format = "%Y-%m-%d")
a03$Time1 <- as.POSIXct(a03$Time, format = "%H:%M")
a03$Date1 <- as.Date(a03$Date)
a03$Day <- wday(a03$Date1, label = TRUE)
str(a03)
## 'data.frame':    32256 obs. of  27 variables:
##  $ tmc1               : Factor w/ 16 levels "TMC106-14016",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ tmc_code           : Factor w/ 16 levels "106-14016","106-14017",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ measurement_tstamp : Factor w/ 2016 levels "9/11/2016 0:00",..: 1885 142 1370 587 954 262 370 746 1983 1318 ...
##  $ speed              : num  18.4 26 24.7 23 31 ...
##  $ average_speed      : int  20 26 26 23 21 26 19 26 25 23 ...
##  $ reference_speed    : int  24 24 24 24 24 24 24 24 24 24 ...
##  $ travel_time_minutes: num  1.05 0.74 0.78 0.84 0.62 0.74 0.77 0.74 0.77 0.74 ...
##  $ confidence_score   : num  28 20 24 20 30 20 30 20 20 30 ...
##  $ cvalue             : num  80 0 40 0 96.4 0 100 0 0 100 ...
##  $ tmc                : Factor w/ 16 levels "106-14016","106-14017",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ road               : Factor w/ 1 level "NIMITZ BLVD": 1 1 1 1 1 1 1 1 1 1 ...
##  $ direction          : Factor w/ 2 levels "NORTHBOUND","SOUTHBOUND": 2 2 2 2 2 2 2 2 2 2 ...
##  $ intersection       : Factor w/ 5 levels "CA-209/ROSECRANS ST",..: 4 4 4 4 4 4 4 4 4 4 ...
##  $ state              : Factor w/ 1 level "CA": 1 1 1 1 1 1 1 1 1 1 ...
##  $ county             : Factor w/ 1 level "SAN DIEGO": 1 1 1 1 1 1 1 1 1 1 ...
##  $ zip                : int  92106 92106 92106 92106 92106 92106 92106 92106 92106 92106 ...
##  $ start_latitude     : num  32.7 32.7 32.7 32.7 32.7 ...
##  $ start_longitude    : num  -117 -117 -117 -117 -117 ...
##  $ end_latitude       : num  32.7 32.7 32.7 32.7 32.7 ...
##  $ end_longitude      : num  -117 -117 -117 -117 -117 ...
##  $ miles              : num  0.32 0.32 0.32 0.32 0.32 ...
##  $ road_order         : int  6 6 6 6 6 6 6 6 6 6 ...
##  $ Time               : chr  "20:00" "19:45" "04:05" "00:50" ...
##  $ Time1              : POSIXct, format: "2017-04-13 20:00:00" "2017-04-13 19:45:00" ...
##  $ Date               : chr  "2016-09-17" "2016-09-11" "2016-09-15" "2016-09-13" ...
##  $ Date1              : Date, format: "2016-09-17" "2016-09-11" ...
##  $ Day                : Ord.factor w/ 7 levels "Sun"<"Mon"<"Tues"<..: 7 1 5 3 4 1 2 3 7 5 ...
aa1 <- subset(a03, direction=="NORTHBOUND")
aa3 <- subset(a03, direction=="SOUTHBOUND")
require(ggplot2)
require(scales)

ggplot(aa1, aes(x=Time1, y=speed)) + 
  geom_point(size=.9, alpha = 0.05, colour="green") + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M"))+theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Nimitz Blvd (Northbound)")

ggplot(aa1, aes(x=Time1, y=speed, colour=Day)) + 
  geom_point(size=.5, alpha = 0.1) + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M")) +
  facet_grid(Day ~.) +
  theme(legend.position="none") +theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Nimitz Blvd (Northbound)")

ggplot(aa3, aes(x=Time1, y=speed)) + 
  geom_point(size=.9, alpha = 0.05, colour="green") + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M"))+theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Nimitz Blvd (Southbound)")

ggplot(aa3, aes(x=Time1, y=speed, colour=Day)) + 
  geom_point(size=.5, alpha = 0.1) + 
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M")) +
  facet_grid(Day ~.) +
  theme(legend.position="none") +theme_bw()+labs(x="Time of Day", y="Speed (mph)", title=
                                                   "Nimitz Blvd (Southbound)")

aa2 <- aggregate(speed ~ Time1+direction+Day, a03, mean)
head(aa2)
##                 Time1  direction Day    speed
## 1 2017-04-13 00:00:00 NORTHBOUND Sun 25.77500
## 2 2017-04-13 00:05:00 NORTHBOUND Sun 24.90750
## 3 2017-04-13 00:10:00 NORTHBOUND Sun 24.62500
## 4 2017-04-13 00:15:00 NORTHBOUND Sun 23.75125
## 5 2017-04-13 00:20:00 NORTHBOUND Sun 23.62500
## 6 2017-04-13 00:25:00 NORTHBOUND Sun 23.62500
dim(aa1)
## [1] 16128    27
dim(aa2)
## [1] 4032    4
colnames(aa2)[2] <- "Direction"
ggplot(aa2, aes(x=Time1, y=speed, colour=Direction)) + 
  geom_path() + geom_point(cex=0.4)+
  scale_x_datetime(breaks=date_breaks("2 hour"), labels=date_format("%H:%M")) +
  facet_grid(Day ~.) +
  theme(legend.position="none") +theme_bw()+labs(x="Time of Day", y="Speed (mph)")