get.distance.counts: Get matrix of trip distance counts

Description Usage Arguments Value Author(s) See Also Examples

View source: R/hmob_funcs.R

Description

The get.distance.counts function calculates a matrix or long-form dataframe of trip distance counts for a temporal interval t given an origin a. Only takes origin district because it uses distances across all destinations.

Usage

1
2
3
4
5
6
7
8
get.distance.counts(
  a,
  t,
  d,
  type = "matrix",
  distID = districtIDs,
  n.cores = NULL
)

Arguments

a

origin district (can take integer ID or character name)

t

character string indicating the temporal interval the count trip distances (e.g. 'month', 'week', 'doy')

d

longform mobility data, expects d.42 data object (trip_durations_longform_metadata_42.csv) or similar

type

return a 'matrix' or a 'dataframe' with counts in longform, default = 'matrix'

distID

district IDs and names, expects districtIDs data object (NamNames.csv), default = districtIDs

n.cores

number cores to use when parallel computing (default = NULL, which uses half available cores)

Value

matrix or dataframe

Author(s)

John Giles

See Also

Other data synthesis: calc.prop.tot.trips(), calc.route.type(), calc.samp.size(), get.crossdist(), get.distance.class(), 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()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Distribution of trip distances that originate from Windhoek East (42)

data(d.42) # same as ./BeyondCommuting2/trip_lengths/trip_durations_longform_metadata_42.csv
data(districtIDs) # same as NamNames.csv
orig <- "Windhoek East"

m <- get.distance.counts(a=orig, t='month', d=d.42, n.cores=4)

see(m)

lattice::wireframe(m[,1:50],
                   xlab = "Month", ylab = "Distance", zlab='Freq',
                   drape = T, colorkey = F,
                   light.source = c(10,0,10), 
                   col.regions = colorRampPalette(c("blue", "red"))(100),
                   screen = list(z = 230, x = -60))

gilesjohnr/hmob documentation built on Aug. 8, 2020, 1:26 a.m.