library(readr)
bike2017<-read.csv("bike2017.csv", sep = ",")
2017 Bike origin-destination matrix and relative frequencies
od<- function(data){
odmatrix<-as.data.frame.matrix(table(data$StartStation.Id,data$EndStation.Id))
frq<-as.data.frame(table(data$StartStation.Id,data$EndStation.Id))
frq<-frq[with(frq, order(Freq,decreasing = T)),]
colnames(frq)<- c("StartStation.Id","EndStation.Id","Freq")
print(head(odmatrix[c(1:10),c(1:10)]))
print(head(frq[c(1:10),]))
}
od(bike2017)
## 1 2 3 4 5 6 7 8 9 10
## 1 200 0 20 21 1 62 2 0 2 2
## 2 0 325 1 7 23 17 4 0 0 1
## 3 12 0 130 18 3 4 1 2 11 10
## 4 1 2 19 85 1 18 0 2 14 7
## 5 0 12 0 0 261 12 4 0 2 1
## 6 35 53 3 15 9 224 61 1 6 2
## StartStation.Id EndStation.Id Freq
## 145966 191 191 20508
## 591750 785 785 13017
## 234334 307 307 10580
## 231178 303 303 10427
## 189361 248 248 9456
## 84424 111 111 9019