Skip to contents

This function takes a data frame of OD data and returns a data frame reporting summary statistics for each unique zone of origin.

Usage

od_aggregate_from(flow, attrib = NULL, FUN = sum, ..., col = 1)

Arguments

flow

A data frame representing origin-destination data. The first two columns of this data frame should correspond to the first column of the data in the zones. Thus in cents_sf(), the first column is geo_code. This corresponds to the first two columns of flow().

attrib

character, column names in sl to be aggregated

FUN

A function to summarise OD data by

...

Additional arguments passed to FUN

col

The column that the OD dataset is grouped by (1 by default, the first column usually represents the origin)

Details

It has some default settings: the default summary statistic is sum() and the first column in the OD data is assumed to represent the zone of origin. By default, if attrib is not set, it summarises all numeric columns.

Examples

od_aggregate_from(flow)
#> # A tibble: 7 × 13
#>   Area.of.re…¹   All Work.…² Under…³ Train Bus..…⁴  Taxi Motor…⁵ Drivi…⁶ Passe…⁷
#>   <chr>        <int>   <int>   <int> <int>   <int> <int>   <int>   <int>   <int>
#> 1 E02002361      336       0       0     1      29     7       2     178      24
#> 2 E02002363      473       0       0     2      42    10       5     218      21
#> 3 E02002367      302       0       0     1      38     6       0     128      15
#> 4 E02002371      633       0       0     2      77    13       0     223      27
#> 5 E02002377      395       0       0     0      61    12       0     115      17
#> 6 E02002382      277       0       0     0      35    20       0      73      11
#> 7 E02002393      400       0       1     6      58    13       1      69      13
#> # … with 3 more variables: Bicycle <int>, On.foot <int>,
#> #   Other.method.of.travel.to.work <int>, and abbreviated variable names
#> #   ¹​Area.of.residence, ²​Work.mainly.at.or.from.home,
#> #   ³​Underground..metro..light.rail..tram, ⁴​Bus..minibus.or.coach,
#> #   ⁵​Motorcycle..scooter.or.moped, ⁶​Driving.a.car.or.van,
#> #   ⁷​Passenger.in.a.car.or.van