library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(lubridate)
library(scales)
library(readxl)
## Warning: package 'readxl' was built under R version 3.2.2
library(reshape2)
library(RCurl)
## Loading required package: bitops
library(rmarkdown)
curr.time<-Sys.time()
rm(list=ls()) # will remove ALL objects
setwd("C:/Projects/0086 TMR AT Benefits/Technical/Intercepts")
#----------------------------------------------------#
# Load data
#----------------------------------------------------#
#--- Intercepts ---#
setwd("C:/Projects/0086 TMR AT Benefits/Technical/Intercepts/short form")
source("survey_22726_R_syntax_file.R")
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
data$submitdate<-as.POSIXct(data$submitdate, format="%d-%m-%Y %H:%M:%S")
data$startlanguage<-NULL
data$token<-NULL
int<-data
int$comment[is.na(int$comment)]<-""
int<-int[int$comment!="Test" & int$comment!="test" ,]
int$path_duration_hrs[is.na(int$path_duration_hrs)]<-0
int$path_duration_mins[is.na(int$path_duration_mins)]<-0
int$path_duration_mins[int$path_duration_hrs>=10 & is.na(int$path_duration_mins)]<-
int$path_duration_hrs
int$path_duration_hrs[int$path_duration_hrs>=10]<-0
int$duration<-int$path_duration_hrs*60 + int$path_duration_mins
int<-int[!is.na(int$mode),]
names(int)[names(int)=="path_distance"]<-"dist"
#--- Online survey ---#
setwd("C:/Projects/0086 TMR AT Benefits/Technical/Intercepts/long form")
source("survey_38578_R_syntax_file.R")
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
data$submitdate<-as.POSIXct(data$submitdate, format="%d-%m-%Y %H:%M:%S")
data$startdate<-as.POSIXct(data$startdate, format="%d-%m-%Y %H:%M:%S")
data$elapsed.time<-data$submitdate-data$startdate
data$lastname<-NULL
data$email<-NULL
data$startlanguage<-NULL
data$sent<-NULL
data$remindersent<-NULL
data$remindercount<-NULL
data$usesleft<-NULL
online<-data
setwd("C:/Projects/0086 TMR AT Benefits/Technical/Intercepts")
#----------------------------------------------------#
# Intercepts
#----------------------------------------------------#
table(int$site)
##
## Bicentennial Bikeway (Milton)
## 126
## Biggera Creek Greenway (Southport)
## 0
## Brassall Bikeway (Ipswich)
## 0
## Enoggera Creek Bikeway (Kelvin Grove)
## 9
## Galeen-Honeyeater Bridge (Burleigh Waters)
## 0
## Gateway North Bikeway (Schulz Canal)
## 54
## North Brisbane Bikeway (Bowen Hills)
## 63
## Kedron Brook Bikeway (Bradshaw Park)
## 61
## Kedron Brook Bikeway (Kalinga Park)
## 95
## Veloway 1 (Greenslopes)
## 0
table(int$site, int$mode)
##
## Bicycle rider Pedestrian
## Bicentennial Bikeway (Milton) 97 29
## Biggera Creek Greenway (Southport) 0 0
## Brassall Bikeway (Ipswich) 0 0
## Enoggera Creek Bikeway (Kelvin Grove) 8 1
## Galeen-Honeyeater Bridge (Burleigh Waters) 0 0
## Gateway North Bikeway (Schulz Canal) 50 4
## North Brisbane Bikeway (Bowen Hills) 59 4
## Kedron Brook Bikeway (Bradshaw Park) 34 27
## Kedron Brook Bikeway (Kalinga Park) 46 49
## Veloway 1 (Greenslopes) 0 0
table(int$site, int$purp)
##
## Commuting to or from work
## Bicentennial Bikeway (Milton) 98
## Biggera Creek Greenway (Southport) 0
## Brassall Bikeway (Ipswich) 0
## Enoggera Creek Bikeway (Kelvin Grove) 5
## Galeen-Honeyeater Bridge (Burleigh Waters) 0
## Gateway North Bikeway (Schulz Canal) 42
## North Brisbane Bikeway (Bowen Hills) 57
## Kedron Brook Bikeway (Bradshaw Park) 15
## Kedron Brook Bikeway (Kalinga Park) 13
## Veloway 1 (Greenslopes) 0
##
## Fitness, recreation or sport
## Bicentennial Bikeway (Milton) 21
## Biggera Creek Greenway (Southport) 0
## Brassall Bikeway (Ipswich) 0
## Enoggera Creek Bikeway (Kelvin Grove) 4
## Galeen-Honeyeater Bridge (Burleigh Waters) 0
## Gateway North Bikeway (Schulz Canal) 10
## North Brisbane Bikeway (Bowen Hills) 5
## Kedron Brook Bikeway (Bradshaw Park) 41
## Kedron Brook Bikeway (Kalinga Park) 80
## Veloway 1 (Greenslopes) 0
##
## Shopping
## Bicentennial Bikeway (Milton) 1
## Biggera Creek Greenway (Southport) 0
## Brassall Bikeway (Ipswich) 0
## Enoggera Creek Bikeway (Kelvin Grove) 0
## Galeen-Honeyeater Bridge (Burleigh Waters) 0
## Gateway North Bikeway (Schulz Canal) 0
## North Brisbane Bikeway (Bowen Hills) 0
## Kedron Brook Bikeway (Bradshaw Park) 0
## Kedron Brook Bikeway (Kalinga Park) 0
## Veloway 1 (Greenslopes) 0
# Check submit dates/times
int$date<-as.Date(int$submitdate, tz="Australia/Brisbane")
int$date.str<-factor(format(int$date, format="%a %d %b-%y"))
int$date.str<-reorder(int$date.str, int$date)
int$time<-as.POSIXct(paste("2015-01-01 ", hour(int$submitdate), ":", minute(int$submitdate), ":", second(int$submitdate), sep=""))
ggplot(int, aes(x=time, y=site)) +
geom_point(shape="|", size=5) +
xlab("") + ylab("") +
facet_wrap(~ date.str)
# Trip distance
int.dist<-int[!is.na(int$dist),] %>%
group_by(site, mode) %>%
summarise(nobs=length(dist), avg.dist=mean(dist),
min.dist=min(dist),
max.dist=max(dist))
int.dist
## Source: local data frame [12 x 6]
## Groups: site
##
## site mode nobs avg.dist
## 1 Bicentennial Bikeway (Milton) Bicycle rider 85 15.844706
## 2 Bicentennial Bikeway (Milton) Pedestrian 27 6.859259
## 3 Enoggera Creek Bikeway (Kelvin Grove) Bicycle rider 8 12.875000
## 4 Enoggera Creek Bikeway (Kelvin Grove) Pedestrian 1 5.000000
## 5 Gateway North Bikeway (Schulz Canal) Bicycle rider 47 22.074468
## 6 Gateway North Bikeway (Schulz Canal) Pedestrian 3 13.333333
## 7 North Brisbane Bikeway (Bowen Hills) Bicycle rider 59 16.367797
## 8 North Brisbane Bikeway (Bowen Hills) Pedestrian 4 14.000000
## 9 Kedron Brook Bikeway (Bradshaw Park) Bicycle rider 32 22.587500
## 10 Kedron Brook Bikeway (Bradshaw Park) Pedestrian 19 4.894737
## 11 Kedron Brook Bikeway (Kalinga Park) Bicycle rider 46 27.852174
## 12 Kedron Brook Bikeway (Kalinga Park) Pedestrian 45 4.811111
## Variables not shown: min.dist (dbl), max.dist (dbl)
ggplot(int, aes(x=dist)) +
geom_density() +
geom_text(data=int.dist, aes(x=Inf, y=Inf, label=paste("n=", nobs, sep="")),
hjust=1.2, vjust=1.2, colour="grey50", size=3) +
coord_cartesian(xlim=c(0, 50)) +
xlab("Distance (km)") + ylab("Density") +
facet_wrap(site ~ mode, scales="free_y", ncol=2)
## Warning: Removed 32 rows containing missing values (stat_density).
ggplot(int, aes(x=dist)) +
stat_ecdf() +
geom_text(data=int.dist, aes(x=48, y=Inf, label=paste("n=", nobs, sep="")),
vjust=1.2, colour="grey50", size=3) +
scale_y_continuous(labels=percent) +
xlab("Distance (km)") + ylab("") +
coord_cartesian(xlim=c(0, 50)) +
facet_wrap(site ~ mode, scales="free_y", ncol=2)
## Warning: Removed 32 rows containing missing values (stat_ecdf).
# Trip duration
int %>%
group_by(site, mode) %>%
summarise(nobs=length(duration), avg.dur=mean(duration),
min.dur=min(duration),
max.dur=max(duration))
## Source: local data frame [12 x 6]
## Groups: site
##
## site mode nobs avg.dur
## 1 Bicentennial Bikeway (Milton) Bicycle rider 97 38.27835
## 2 Bicentennial Bikeway (Milton) Pedestrian 29 57.27586
## 3 Enoggera Creek Bikeway (Kelvin Grove) Bicycle rider 8 40.62500
## 4 Enoggera Creek Bikeway (Kelvin Grove) Pedestrian 1 60.00000
## 5 Gateway North Bikeway (Schulz Canal) Bicycle rider 50 52.16000
## 6 Gateway North Bikeway (Schulz Canal) Pedestrian 4 55.00000
## 7 North Brisbane Bikeway (Bowen Hills) Bicycle rider 59 44.81356
## 8 North Brisbane Bikeway (Bowen Hills) Pedestrian 4 36.25000
## 9 Kedron Brook Bikeway (Bradshaw Park) Bicycle rider 34 66.23529
## 10 Kedron Brook Bikeway (Bradshaw Park) Pedestrian 27 47.40741
## 11 Kedron Brook Bikeway (Kalinga Park) Bicycle rider 46 85.65217
## 12 Kedron Brook Bikeway (Kalinga Park) Pedestrian 49 55.13878
## Variables not shown: min.dur (dbl), max.dur (dbl)
ggplot(int, aes(x=duration)) +
geom_density() +
coord_cartesian(xlim=c(0, 120)) +
facet_wrap(site ~ mode, ncol=2)
# Alternative mode
table(int$path_alt_other)
##
## Kept going Run Same trip
## 1 1 1
## Still this path Taken same path Train & Bus
## 1 1 1
## Walk Walk in the streets
## 2 1
oth.l<-c("Walk", "Taken same path", "Still this path", "Walk in the streets", "Same trip")
int$path_alt[int$path_alt_other %in% oth.l]<-"Taken a different route"
int$path_alt_other[int$path_alt_other %in% oth.l]<-""
table(int$path_alt_other)
##
## Kept going Run Train & Bus
## 6 1 1 1
levels(int$path_alt)[levels(int$path_alt)=="Taken a different route"]<-"Taken a\ndifferent route"
levels(int$path_alt)[levels(int$path_alt)=="Would not have travelled"]<-"Would not\nhave travelled"
levels(int$path_alt)[levels(int$path_alt)=="Car - as driver"]<-"Car driver"
levels(int$path_alt)[levels(int$path_alt)=="Car - as passenger"]<-"Car passenger"
table(int$site, int$path_alt)
##
## Taken a\ndifferent route
## Bicentennial Bikeway (Milton) 48
## Biggera Creek Greenway (Southport) 0
## Brassall Bikeway (Ipswich) 0
## Enoggera Creek Bikeway (Kelvin Grove) 9
## Galeen-Honeyeater Bridge (Burleigh Waters) 0
## Gateway North Bikeway (Schulz Canal) 37
## North Brisbane Bikeway (Bowen Hills) 44
## Kedron Brook Bikeway (Bradshaw Park) 33
## Kedron Brook Bikeway (Kalinga Park) 60
## Veloway 1 (Greenslopes) 0
##
## Would not\nhave travelled
## Bicentennial Bikeway (Milton) 14
## Biggera Creek Greenway (Southport) 0
## Brassall Bikeway (Ipswich) 0
## Enoggera Creek Bikeway (Kelvin Grove) 0
## Galeen-Honeyeater Bridge (Burleigh Waters) 0
## Gateway North Bikeway (Schulz Canal) 3
## North Brisbane Bikeway (Bowen Hills) 1
## Kedron Brook Bikeway (Bradshaw Park) 20
## Kedron Brook Bikeway (Kalinga Park) 21
## Veloway 1 (Greenslopes) 0
##
## Car driver Car passenger
## Bicentennial Bikeway (Milton) 12 1
## Biggera Creek Greenway (Southport) 0 0
## Brassall Bikeway (Ipswich) 0 0
## Enoggera Creek Bikeway (Kelvin Grove) 0 0
## Galeen-Honeyeater Bridge (Burleigh Waters) 0 0
## Gateway North Bikeway (Schulz Canal) 9 3
## North Brisbane Bikeway (Bowen Hills) 3 0
## Kedron Brook Bikeway (Bradshaw Park) 3 0
## Kedron Brook Bikeway (Kalinga Park) 5 0
## Veloway 1 (Greenslopes) 0 0
##
## Motorcycle Train Bus Ferry
## Bicentennial Bikeway (Milton) 1 25 22 2
## Biggera Creek Greenway (Southport) 0 0 0 0
## Brassall Bikeway (Ipswich) 0 0 0 0
## Enoggera Creek Bikeway (Kelvin Grove) 0 0 0 0
## Galeen-Honeyeater Bridge (Burleigh Waters) 0 0 0 0
## Gateway North Bikeway (Schulz Canal) 0 1 1 0
## North Brisbane Bikeway (Bowen Hills) 1 7 3 2
## Kedron Brook Bikeway (Bradshaw Park) 0 0 4 0
## Kedron Brook Bikeway (Kalinga Park) 0 1 1 0
## Veloway 1 (Greenslopes) 0 0 0 0
##
## Taxi Don't know
## Bicentennial Bikeway (Milton) 0 0
## Biggera Creek Greenway (Southport) 0 0
## Brassall Bikeway (Ipswich) 0 0
## Enoggera Creek Bikeway (Kelvin Grove) 0 0
## Galeen-Honeyeater Bridge (Burleigh Waters) 0 0
## Gateway North Bikeway (Schulz Canal) 0 0
## North Brisbane Bikeway (Bowen Hills) 0 1
## Kedron Brook Bikeway (Bradshaw Park) 0 1
## Kedron Brook Bikeway (Kalinga Park) 0 3
## Veloway 1 (Greenslopes) 0 0
int.no.path<-int[!is.na(int$path_alt) & int$path_alt!="Don't know",] %>%
group_by(site, mode, path_alt) %>%
summarise(nobs=length(site))
int.no.path<-int.no.path %>%
group_by(site, mode) %>%
mutate(ngrp=sum(nobs), perc=nobs/ngrp)
ggplot(int.no.path, aes(x=path_alt, y=perc)) +
geom_bar(stat="identity") +
geom_text(aes(x=Inf, y=Inf, label=paste("n=", ngrp)),
colour="grey50", hjust=1.2, vjust=1.2, size=3) +
geom_text(aes(y=perc+0.1, label=paste(round(perc*100, 0), "%", sep="")),
colour="grey40", size=3) +
scale_y_continuous(labels=percent) +
xlab("") + ylab("") +
facet_wrap(site ~ mode, ncol=2)
ftpUpload(“Localfile.html”, “ftp://User:Password@FTPServer/Destination.html”) ftpUpload(“Localfile.html”, “ftp://bike0459:Elephant11!@5c6.209.myftpupload.com/Destination.html") 5c6.209.myftpupload.com