Exercise

For the week of your birthday in 2016, read in the pedestrian counts for all the sensors in Melbourne, using code like this:

myweek <- walk_melb(ymd("2016-10-31"), ymd("2016-11-06")) # Monday through Sunday
  1. (1pt) Who is the author of the rwalkr package? EARO WANG
  2. (1pt) How many sensors are there in your data set? 43
  3. (2pts) Create a week day variable, which specifies that the day in this order Mon, Tue, … and count the number of pedestrians each day at “QV Market-Peel St”. What is the busiest day?
myweek <- myweek %>% mutate(day = wday(Date, label=TRUE, abbr=TRUE, week_start = 1))
qv <- myweek %>% 
  filter(Sensor == "QV Market-Peel St") %>% 
  group_by(day) %>% 
  summarise(n=sum(Count, na.rm=T))
qv
# A tibble: 7 x 2
  day       n
  <ord> <int>
1 Mon    2085
2 Tue    1630
3 Wed    2336
4 Thu    3258
5 Fri    3156
6 Sat    3347
7 Sun    3105
qv %>% filter(n==max(n))
# A tibble: 1 x 2
  day       n
  <ord> <int>
1 Sat    3347
  1. (2pts) Make a plot of Count by Time separately for each day, for “QV Market-Peel St”. Write a couple of sentences describing the pattern.

QV Market-Peel St has a big peak in the middle of the weekend days. The week days are mixed. Monday and Wednesday have triple peaks, which look like commuter and lunch time traffic. These patterns are not there on Tuesday, Thursday or Friday. Tuesday has the smallest number of people walking by. Thursday and Friday appear to have the middle of the day peak, but also possibly the commuter traffic as well, which makes for a difficult pattern detection. The opening hours for QV market are Tues, Thu-Sun, and it looks like the Thu-Sun are busy market days, as well as commuting, but Tues doesn’t have a large number of people attending.

  1. (3pts) Plot a google map of Melbourne, with the pedestrian sensor locations overlaid. Colour the points by the total number of pedestrians during the week. Describe the spatial pattern, where most people are walking.
melb <- get_map(location=c(144.9631, -37.8136), zoom=14)
loc <- pull_sensor()
loc <- loc %>% 
  filter(Sensor %in% myweek$Sensor)
# sens_count <- myweek %>% group_by(Sensor) %>% summarise(n=sum(Count, na.rm=TRUE)) %>%
#   left_join(loc, by="Sensor")
sens_count <- myweek %>% group_by(Sensor) %>% summarise(n=sum(Count, na.rm=TRUE)) %>%
  left_join(loc, by="Sensor")
ggmap(melb) + geom_point(data=sens_count, aes(x=Longitude, y=Latitude, colour=n), size=4, alpha=0.7) +
  scale_colour_distiller(palette="YlOrRd")