The data

The data highlights the details of public bicycle trips in London 2017.

head(bike2017)
## # A tibble: 6 x 7
##   Duration End.Date         EndStation.Id Start.Date       StartStation.Id
##      <int> <chr>                    <int> <chr>                      <int>
## 1     3600 03/01/2017 07:42           510 03/01/2017 06:42             201
## 2      180 03/01/2017 19:03           386 03/01/2017 19:00             381
## 3      300 03/01/2017 17:23            68 03/01/2017 17:18             109
## 4      360 03/01/2017 17:39           254 03/01/2017 17:33              68
## 5      300 02/01/2017 16:03           378 02/01/2017 15:58             219
## 6      300 01/01/2017 11:09           356 01/01/2017 11:04             219
## # ... with 2 more variables: StartStation.Name <chr>,
## #   EndStation.Name <chr>

Functions

###season 
Season <- function(data2) {
  d<- as.Date(strptime(data2$Start.Date,format="%d/%m/%Y %H:%M",tz="UTC"))
  WS <- as.Date("21/12/2017", format = "%d/%m/%Y") # Winter 
  SE <- as.Date("20/3/2017",  format = "%d/%m/%Y") # Spring 
  SS <- as.Date("21/6/2017",  format = "%d/%m/%Y") # Summer 
  FE <- as.Date("22/9/2017",  format = "%d/%m/%Y") # Fall
  
  ifelse (d >= WS | d < SE, "Winter",
          ifelse (d >= SE & d < SS, "Spring",
                  ifelse (d >= SS & d < FE, "Summer", "Autumn")))
}
bike2017$season<- Season(data2=bike2017)

###weekdays

bike2017$weekdays<-weekdays(
  strptime(bike2017$Start.Date,format="%d/%m/%Y %H:%M",tz="UTC")
  
  
)
###weekdays and weekends

bike2017$week <- ifelse(bike2017$weekdays %in% c("Saturday", "Sunday"), "weekend", "weekday")
#levels(factor(bike2017$season))
bike2017$weekdays <- factor(bike2017$weekdays,levels = c('Monday','Tuesday',"Wednesday","Thursday",
                                             "Friday","Saturday","Sunday"))

The number of trips by weekdays and season

sjp.frq(bike2017$weekdays)

sjp.frq(bike2017$season)

2017 routa visualisation

map<- get_map(location = c(lon =mean(x$s.lon),lat = mean(x$s.lat)),
              source="google",maptype="roadmap",zoom=11)
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=51.507274,-0.129542&zoom=11&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false
ggmap(map)+
  geom_segment(data=x,aes(x=s.lon,y=s.lat,xend=e.lon, yend=e.lat,alpha=freq),
               colour= "black",size=0.00001)+
  theme(plot.title = element_text(hjust = 0.5,size = 13))+
  xlim(range(x$s.lon))+
  ylim(range(x$s.lat))+
  geom_point(data=x,aes(x=s.lon,y=s.lat),size=0.001,alpha=0.3)+
  
  geom_label_repel(data=scj, aes(x=s.lon,y=s.lat,label=StartStation.Name),
                   color="blue",nudge_y = 0.03,nudge_x = -0.1,label.size = 0.05,
                   size=5,alpha=0.6
  )+
  #    arrow =arrow(length =unit(0.5,"cm")))+
  geom_label_repel(data=ecj, aes(x=e.lon,y=e.lat,label=EndStation.Name),
                   color="red",segment.size = 0.5,segment.colour = "red",
                   #arrow = arrow(length = unit(0.5,"cm")),
                   nudge_y = -0.03,nudge_x = 0.15,size=5,alpha=0.6)+
  theme(plot.caption = element_text(hjust=0.5))+
    geom_segment(data=x,aes(x=s.lon,y=s.lat,xend=e.lon, yend=e.lat,alpha=freq),
                 colour= "black",size=0.00001)+
    geom_segment(data=x,aes(x=s.lon,y=s.lat,xend=e.lon, yend=e.lat,alpha=freq),
                 colour= "black",size=0.00001)+
    geom_segment(data=x,aes(x=s.lon,y=s.lat,xend=e.lon, yend=e.lat,alpha=freq),
                 colour= "black",size=0.00001)+
    geom_segment(data=x,aes(x=s.lon,y=s.lat,xend=e.lon, yend=e.lat,alpha=freq),
                 colour= "black",size=0.00001)+
    scale_alpha_continuous(range = c(0,0.3))
## Scale for 'x' is already present. Adding another scale for 'x', which
## will replace the existing scale.
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.

The above plot shows the route pattern of the year 2017. Each black line represents a route between two stations, the visibility of the lines is determined by the frequency of the route. The top five most visited start stations are labelled in blue and the top five end stations are shown in red. The most popular routes are around Waterloo, Kings Cross (Belgrove St) stations and around the Hyde Park area for both start and end stations.