create dummy transaction data
Usage
create_dummy_transaction_data(
people = 100,
size = 2,
spatiotemporal = FALSE,
places = 50,
days = 30,
seed = NULL
)Arguments
- people
number of people
- size
mean record number
- spatiotemporal
add the `PLACE` and `TIME` columns described above (default FALSE)
- places
number of distinct locations, used only when `spatiotemporal = TRUE` (default 50)
- days
length of the observation window in days, used only when `spatiotemporal = TRUE` (default 30)
- seed
integer seed, or NULL (the default) to use the ambient RNG stream as the function always has
Value
a tibble with columns ROW_NUMBER, ID, NUM_STATIC, NUM_DYNAMIC, BIN, CHAR – plus PLACE and TIME when `spatiotemporal = TRUE` – containing `people * size` rows of randomly generated dummy transaction data.
Spatio-temporal columns
With `spatiotemporal = TRUE` two further columns are appended, so that [spatiotemporal_unicity()] (Issue #24) has something with the shape of a mobility trace to measure:
- `PLACE`
a zero-padded location code, `"P001"` upwards. Codes are assigned so that **sort order tracks proximity** – `"P004"` is next to `"P005"` – because that is what [coarsen_place()] assumes when it merges neighbouring locations into a coarser grid.
- `TIME`
hours since the start of the observation window, so a `time_resolution` of 1 means hourly and 24 means daily.
Each person is given a home location, a small repertoire of places around it, and a preferred hour of the day; events are drawn from those habits. Without per-person structure every trace would be a uniform draw from the same pool and the unicity curve would say nothing about the method.
The extra columns are **off by default** so that the returned schema is unchanged for existing callers, and they are drawn *after* the original columns, so a given seed produces the same `NUM_STATIC` / `NUM_DYNAMIC` / `BIN` / `CHAR` either way.
Examples
data_tran = create_dummy_transaction_data(people = 10, size = 4)
create_dummy_transaction_data(people = 10, size = 4, spatiotemporal = TRUE, seed = 1)
#> # A tibble: 40 × 8
#> ROW_NUMBER ID NUM_STATIC NUM_DYNAMIC BIN CHAR PLACE TIME
#> <int> <int> <dbl> <dbl> <dbl> <chr> <chr> <dbl>
#> 1 1 9 10 0.245 0 dv P028 458
#> 2 2 4 10 0.0707 0 bY P012 690
#> 3 3 7 10 0.0995 0 Wz P009 217
#> 4 4 1 10 0.316 1 Vg P046 661
#> 5 5 2 10 0.519 1 bE P017 181
#> 6 6 7 10 0.662 0 Gj P009 1
#> 7 7 2 10 0.407 0 SA P019 665
#> 8 8 3 10 0.913 0 k6 P044 316
#> 9 9 1 10 0.294 1 rc P001 277
#> 10 10 5 10 0.459 1 YK P014 691
#> # ℹ 30 more rows