Skip to contents

A collection of mock inputs for experimenting with functions in the xmap package. named_ objects are either named vectors or nested lists. df_ objects may contain source-target pairs (no weights), or weighted source-target links.

Usage

mock

Format

mock

A list with:

named_ctr_iso3c

named vector with 249 elements. Names are ISO-3 country codes, values are ISO English country names. Retrieved from countrycode package: https://github.com/vincentarelbundock/countrycode

df_anzsco21

tibble with 51 rows and 4 columns. Contains major and submajor occupation codes and descriptions for ANZSCO21. Retrieved from strayr package: https://github.com/runapp-aus/strayr

xmap_abc

xmap_df: lower -> upper BY share. Mock crossmap with 6 links including one-to-one, one-to-many and many-to-one relations.

named_aus

named list with 1 element named "AUS" containing codes for the Australian states

df_aus_pop

tibble containing 2022 population figures for Australia by state. Retrieved from: https://www.abs.gov.au/statistics/people/population/national-state-and-territory-population/jun-2022

Examples

links_aus_agg <- mock$named_aus |>
  as_pairs_from_named(names_to = "ctr", values_to = "state") |>
  add_weights_unit() |>
  dplyr::select(ctr, state, weights) |>
  verify_links_as_xmap(from = state, to = ctr, weights)
links_aus_agg
#> # A tibble: 8 × 3
#>   ctr   state  weights
#>   <chr> <chr>    <dbl>
#> 1 AUS   AU-NSW       1
#> 2 AUS   AU-QLD       1
#> 3 AUS   AU-SA        1
#> 4 AUS   AU-TAS       1
#> 5 AUS   AU-VIC       1
#> 6 AUS   AU-WA        1
#> 7 AUS   AU-ACT       1
#> 8 AUS   AU-NT        1

links_aus_split_equal <- links_aus_agg |>
  add_weights_equal(from = ctr, to = state) |>
  dplyr::select(ctr, state, weights) |>
  verify_links_as_xmap(from = ctr, to = state, weights)
links_aus_split_equal
#> # A tibble: 8 × 3
#>   ctr   state  weights
#>   <chr> <chr>    <dbl>
#> 1 AUS   AU-NSW   0.125
#> 2 AUS   AU-QLD   0.125
#> 3 AUS   AU-SA    0.125
#> 4 AUS   AU-TAS   0.125
#> 5 AUS   AU-VIC   0.125
#> 6 AUS   AU-WA    0.125
#> 7 AUS   AU-ACT   0.125
#> 8 AUS   AU-NT    0.125

links_aus_split_pop <- mock$df_aus_pop |>
  add_weights_prop(from = ctr, to = state, prop = pop)
links_aus_split_pop
#> # A tibble: 8 × 5
#>   state_name                   state      pop ctr   weights
#>   <chr>                        <chr>    <dbl> <chr>   <dbl>
#> 1 New South Wales              AU-NSW 8153600 AUS   0.314  
#> 2 Victoria                     AU-VIC 6613700 AUS   0.255  
#> 3 Queensland                   AU-QLD 5322100 AUS   0.205  
#> 4 South Australia              AU-SA  1820500 AUS   0.0701 
#> 5 Western Australia            AU-WA  2785300 AUS   0.107  
#> 6 Tasmania                     AU-TAS  571500 AUS   0.0220 
#> 7 Northern Territory           AU-NT   250600 AUS   0.00965
#> 8 Australian Capital Territory AU-ACT  456700 AUS   0.0176