This Assignment will be about assessing cyclists behavior on Melbourne Bicycle tracks / routes in and around the Melbourne CBD which may include neighboring suburbs
https://www.data.vic.gov.au/data/dataset/bicycle-volume-and-speed
http://data.vicroads.vic.gov.au/Metadata/VicRoads%20Bicycle%20Volume%20and%20Speed%20Data.html
VicRoads Bicycle Volume and Speed Data Bicycle Volume and speed Cycling flows in both directions recorded at 42 off-road counter sites and 4 on-road counter sites .
Last Updated 15/05/2017
http://rpubs.com/fast_Eddie/432401
IND_D208_X6411_16 <- read.csv("C:/Users/dan/Desktop/a Vis 3/site x6411 2106 -17 -18/IND_D208_X6411_16.csv", stringsAsFactors = FALSE)
#View(IND_D208_X6411_16)
IND_D208_X6411_17 <- read_csv("C:/Users/dan/Desktop/a Vis 3/site x6411 2106 -17 -18/IND_D208_X6411_17.csv")
## Parsed with column specification:
## cols(
## DATA_TYPE = col_character(),
## TIS_DATA_REQUEST = col_integer(),
## SITE_XN_ROUTE = col_integer(),
## LOC_LEG = col_integer(),
## DATE = col_character(),
## TIME = col_time(format = ""),
## CLASS = col_integer(),
## LANE = col_integer(),
## SPEED = col_double(),
## WHEELBASE = col_double(),
## HEADWAY = col_double(),
## GAP = col_double(),
## AXLE = col_integer(),
## AXLE_GROUPING = col_integer(),
## RHO = col_double(),
## VEHICLE = col_character(),
## DIRECTION = col_character()
## )
#View(IND_D208_X6411_17)
IND_D208_X6411_18 <- read_csv("C:/Users/dan/Desktop/a Vis 3/site x6411 2106 -17 -18/IND_D208_X6411_18.csv")
## Parsed with column specification:
## cols(
## DATA_TYPE = col_character(),
## TIS_DATA_REQUEST = col_integer(),
## SITE_XN_ROUTE = col_integer(),
## LOC_LEG = col_integer(),
## DATE = col_character(),
## TIME = col_time(format = ""),
## CLASS = col_integer(),
## LANE = col_integer(),
## SPEED = col_double(),
## WHEELBASE = col_double(),
## HEADWAY = col_double(),
## GAP = col_double(),
## AXLE = col_integer(),
## AXLE_GROUPING = col_integer(),
## RHO = col_double(),
## VEHICLE = col_character(),
## DIRECTION = col_character()
## )
#View(IND_D208_X6411_18)
I’m going to choose Date, Time, speed, Gap, and Direction as the Variables I will be looking at
The Question is how many people , in what direction and at what time for site 6411
# Pre Process and Extract Section / columns /
library(hms)
############################### 2016
bike16 <- IND_D208_X6411_16[ c(6, 9, 12,17 )] #c(5, 6, 9, 12, 17)
bike16$GAP <- round((bike16$GAP / 60), 0)
bike16$SPEED <- round(bike16$SPEED, 0)
bike16$TIME <- as.hms(bike16$TIME) # Change to same str as yrs 17, 18 with package hms
############################### 2017
bike17 <- IND_D208_X6411_17[ c(6, 9, 12, 17 )]
bike17$GAP <- round((bike17$GAP / 60), 0)
bike17$SPEED <- round(bike17$SPEED, 0)
############################### 2018
bike18 <- IND_D208_X6411_18[ c(6, 9, 12, 17 )]
bike18$GAP <- round((bike18$GAP / 60), 0)
bike18$SPEED <- round(bike18$SPEED, 0)
#########################
## Separate into directions
bike18 <- bike18 %>% mutate( ifelse(bike18$DIRECTION == 'S', "1", "0 "))
bike18 <- bike18 %>% mutate( ifelse(bike18$DIRECTION == 'N', "1", "0 "))
#View(bike18)
## Change col Names
#colnames(bike18)[4] <- "Combined"
colnames(bike18)[5] <- "South"
colnames(bike18)[6] <- "North"
#colnames(bike18)
############################
# n = sum(is.na(bike16))
# n
# n1 = sum(is.na(bike17))
# n1
# n2 = sum(is.na(bike18))
# n2
#View(bike18)
# str(bike16)
# str(bike17)
#str(bike18)
## Single file Shiny app.R ------------------ working
# Load packages and prepare data
#library(ggplot2)
#library(shiny)
#library(dplyr)
#library(lubridate)
#library(htmlwidgets)
# Assign server function
#library(plotly)
server <- function(input, output) {
output$Plot3 <- renderPlot({
ggplot(data = bike16, aes(x = TIME, y = get(input$var1))) +
geom_count( colour="#999999") + labs(y = input$var) +
labs(
x="Time = 24 hrs"
)
})
output$Plot2 <- renderPlot({
ggplot(data = bike17, aes(x = TIME, y = get(input$var2))) + #"#56B4E9"
geom_count( colour="#FF0099") + labs(y = input$var) +
labs(
x="Time = 24 hrs"
)
})
output$Plot1 <- renderPlot({
ggplot(data = bike18, aes(x = TIME, y = get(input$var3))) +
geom_count( colour="#0072B2") + labs(y = input$var) +
labs(
x="Time = 24 hrs"
)
})
}
# Create ui
ui <- fluidPage(
titlePanel("Bike Data for Melbourne : Site 6411"),
sidebarLayout(
sidebarPanel(
selectInput("var1", "Bike Path Traffic :: 28/12/2015 - 3/1/2016:: Top", colnames(bike18[2:4]),
selected = colnames(bike18[3])),
selectInput("var2", "Bike Path Traffic :: 18/9/2017 - 25/9/2017:: Middle", colnames(bike17[2:4]),
selected = colnames(bike17[3])),
selectInput("var3", "Bike Path Traffic :: 15/1/2018 - 21/1/2018:: Bottom ", colnames(bike16[2:4]),
selected = colnames(bike16[3])),
#checkboxInput("var1n", "North", FALSE),
# actionButton("go", "North"),
# #numericInput("n", "n", 50),
# plotOutput("output$Plot1n"),
HTML(
paste('<br/>', #'<br/>',
h1("Bike Path Usuage. \n"),'<br/>', ## br/ is html \n equivalent
h3("Speed is in km/hr. \n") , #'<br/>',
h3("Gap is the time between each cyclist \n"), #'<br/>',
h3("measured in minutes. \n"), #'<br/>',
h3("Directions are North or South. \n"),'<br/>' , ## h1-6 is text height
h4("Time and n are accumulated values per graph. \n"),'<br/>' ,
h4("Time = 24hrs \n"),
h4("n = number of people (averaged) \n")
))
),
mainPanel(plotOutput("Plot3", height=260),
plotOutput("Plot2", height=260),
plotOutput("Plot1", height=260)
)))
## Deploy app
#shinyApp(ui = ui, server = server ) ## this below code corrected from half page to full page
shinyApp(ui = ui, server = server, options = list(height = 1080)) ## needed this for the deploy
This was an interesting and in the end somewhat satisfying project to complete. The data itself shows an increasing trend towards cycle usage which can only be a good thing, it also infers that as the inner city population grows cycle paths will need to grow also. It is my belief these paths should be kept away from interactions with road traffic or at least minimized where ever possible. A cleaner greener more vibrant population would be an achievement certainly worth aiming for. What was a surprise although not really evident in large numbers was a slight increase in bike usage which included volume and speed, it seems as though bikes are getting faster or perhaps the cycle population is getting fitter ? Unfortunately the visual once deployed to shiny isn’t as clear as it is when being run on my pc using rmd, it does though I believe show an increasing usage of these paths.
The only downside to this last Assign for me was not being able to integrate a plotly hover thing over the data, I’m sure its do-able however in all the attempts I made to find a way, I just couldn’t get there.
As mentioned at the start of this Assignment, all data was accessed from the above mentioned sites.