Description Usage Arguments Value Author(s) See Also Examples
This function calculates the observed number of trips of each of the four route types for each temporal unit in a mobility data array. The route types are defined by the population density of the origin and destination districts:
High density to high density (HH)
High density to low density (HL)
Low density to high density (LH)
Low density to low density (LL)
1 | calc.route.type(m, hi, lo, per.route = FALSE)
|
m |
A 3-dimensional data array produced by the |
hi |
A vector of numerical district IDs in the high population density group |
lo |
A vector of numerical district IDs in the low population density group |
per.route |
logical indicating whether or not to scale number of trips by the number of routes in each route type |
A five column dataframe. If per.route = FALSE
, then counts represent raw number of total trips. If per.route = TRUE
, then counts represent total trips per route.
John Giles
Other data synthesis:
calc.prop.tot.trips()
,
calc.samp.size()
,
get.crossdist()
,
get.distance.class()
,
get.distance.counts()
,
get.distance.matrix()
,
get.district.names.xy()
,
get.district.pop()
,
get.duration.counts()
,
get.holidays()
,
get.sparse.mob.matrix()
,
get.stay.data()
,
get.subsamp()
,
get.xy.counts()
,
mob.data.array()
,
parse.longform()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # Subset of 5 high pop density and 7 low pop density
d <- read.csv("BeyondCommuting2/trip_lengths/trip_durations_longform_metadata_12_dists_hi_lo_dens.csv", stringsAsFactors=F)
pop <- read.csv("./data/population_data.csv")
cutoff <- 980
hi <- pop$ID_2[pop$density >= cutoff]
lo <- pop$ID_2[pop$density < cutoff]
m <- mob.data.array(orig=d$from,
dest=d$to,
time=d$day, # total trip counts for each unique day
count=d$count,
name='movement')
str(m)
par(mfrow=c(1,2))
p1 <- calc.route.type(m, hi, lo, per.route=FALSE) # Raw number of trips in each route type
plotrix::violin_plot(p1[,2:5], violin_width = 1, box_width=0.05,
xlab='Route type', ylab='Raw total number trips', main=NULL,
x_axis_labels=c('High to high', 'High to low', 'Low to high', 'Low to low'))
p2 <- calc.route.type(m, hi, lo, per.route=TRUE) # Total number of trips per route
plotrix::violin_plot(p2[,2:5], violin_width = 1, box_width=0.05,
xlab='Route type', ylab='Total trips per route', main=NULL,
x_axis_labels=c('High to high', 'High to low', 'Low to high', 'Low to low'))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.