This Assignment will be about assessing cyclists behaviour on Melbourne Bicycle tracks / routes in and around the Melbourne CBD which may include neighbouring 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
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 ppl , in what direction , for site 6411
# extract rows / 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
############################### 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
#head(bike18)
#colnames(bike18)[4] <- "Combined"
colnames(bike18)[5] <- "South"
colnames(bike18)[6] <- "North"
#colnames(bike18)
#bike18 <- bike18[ c(1, 2, 3, 4, 5, 6 )]
#bike18 <- cbind.data.frame(bike18$TIME, bike18$SPEED, bike18$GAP, bike18$DIRECTION,
# bike18$South, bike18$North)
#
# bike18$South <- as.numeric(bike18$South)
# bike18$North <- as.numeric(bike18$North)
#
# bike18 <- cbind.data.frame(bike18)
#View(bike18)
#write.csv(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)
##
## Attaching package: 'shiny'
## The following object is masked from 'package:rsconnect':
##
## serverInfo
#library(dplyr)
#library(lubridate)
#library(htmlwidgets)
# Assign server function
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 = 24hrs , accumulated across dates per graph. \n"),
h4("n = number of people , accumulated across dates per graph \n")
))
),
mainPanel(plotOutput("Plot3", height=260),
plotOutput("Plot2", height=260),
plotOutput("Plot1", height=260)
)))
## Deploy app
shinyApp(ui = ui, server = server )