This function builds unique character string identifiers for all origins and destinations.

get_unique_ids(
  data,
  orig = TRUE,
  dest = TRUE,
  adm_start = NULL,
  adm_stop = NULL,
  name_class = "character"
)

Arguments

data

generalized data frame described in travel_data_template

orig

logical indicating whether to include unique coordinates from origin locations (default=TRUE)

dest

logical indicating whether to include unique coordinates from destination locations (default=TRUE)

adm_start

highest administrative level to include in unique names (default = NULL, which uses highest observed in the data)

adm_stop

lowest administrative level to include in unique names (default = NULL, which uses lowest observed in the data)

name_class

character indicating whether unique names should be either a unique character string (name_class = "character") or a unique integer code (name_class = "numeric")

Value

two column dataframe containing unique names

See also

Author

John Giles

Examples

get_unique_ids(travel_data_sim)
#> orig_id dest_id #> 1 A_B_O A_B_G #> 2 A_B_S A_B_U #> 3 A_B_N A_B_L #> 4 A_B_C A_B_O #> 5 A_B_R A_B_M #> 6 A_B_V A_B_G #> 7 A_B_K A_B_I #> 8 A_B_E A_B_I #> 9 A_B_T A_B_J #> 10 A_B_N A_B_W #> 11 A_B_V A_B_U #> 12 A_B_Y A_B_G #> 13 A_B_Z A_B_U #> 14 A_B_E A_B_F #> 15 A_B_S A_B_Y #> 16 A_B_Y A_B_B #> 17 A_B_Y A_B_E #> 18 A_B_I A_B_H #> 19 A_B_C A_B_L #> 20 A_B_H A_B_M #> 21 A_B_Z A_B_R #> 22 A_B_G A_B_A #> 23 A_B_J A_B_Y #> 24 A_B_I A_B_Y #> 25 A_B_S A_B_F #> 26 A_B_D A_B_U #> 27 A_B_N A_B_O #> 28 A_B_Q A_B_I #> 29 A_B_K A_B_O #> 30 A_B_O A_B_O #> 31 A_B_S A_B_S #> 32 A_B_N A_B_N #> 33 A_B_C A_B_C #> 34 A_B_R A_B_R #> 35 A_B_V A_B_V #> 36 A_B_K A_B_K #> 37 A_B_E A_B_E #> 38 A_B_T A_B_T #> 39 A_B_Y A_B_Y #> 40 A_B_Z A_B_Z #> 41 A_B_I A_B_I #> 42 A_B_H A_B_H #> 43 A_B_G A_B_G #> 44 A_B_J A_B_J #> 45 A_B_D A_B_D #> 46 A_B_Q A_B_Q
# Starting at admin level 1 get_unique_ids(travel_data_sim, adm_start=1)
#> orig_id dest_id #> 1 B_O B_G #> 2 B_S B_U #> 3 B_N B_L #> 4 B_C B_O #> 5 B_R B_M #> 6 B_V B_G #> 7 B_K B_I #> 8 B_E B_I #> 9 B_T B_J #> 10 B_N B_W #> 11 B_V B_U #> 12 B_Y B_G #> 13 B_Z B_U #> 14 B_E B_F #> 15 B_S B_Y #> 16 B_Y B_B #> 17 B_Y B_E #> 18 B_I B_H #> 19 B_C B_L #> 20 B_H B_M #> 21 B_Z B_R #> 22 B_G B_A #> 23 B_J B_Y #> 24 B_I B_Y #> 25 B_S B_F #> 26 B_D B_U #> 27 B_N B_O #> 28 B_Q B_I #> 29 B_K B_O #> 30 B_O B_O #> 31 B_S B_S #> 32 B_N B_N #> 33 B_C B_C #> 34 B_R B_R #> 35 B_V B_V #> 36 B_K B_K #> 37 B_E B_E #> 38 B_T B_T #> 39 B_Y B_Y #> 40 B_Z B_Z #> 41 B_I B_I #> 42 B_H B_H #> 43 B_G B_G #> 44 B_J B_J #> 45 B_D B_D #> 46 B_Q B_Q
# Use numeric facto levels get_unique_ids(travel_data_sim, name_class='numeric')
#> orig_id dest_id #> 1 001_001_015 001_001_007 #> 2 001_001_018 001_001_020 #> 3 001_001_014 001_001_012 #> 4 001_001_003 001_001_015 #> 5 001_001_017 001_001_013 #> 6 001_001_021 001_001_007 #> 7 001_001_011 001_001_009 #> 8 001_001_005 001_001_009 #> 9 001_001_019 001_001_010 #> 10 001_001_014 001_001_022 #> 11 001_001_021 001_001_020 #> 12 001_001_023 001_001_007 #> 13 001_001_024 001_001_020 #> 14 001_001_005 001_001_006 #> 15 001_001_018 001_001_023 #> 16 001_001_023 001_001_002 #> 17 001_001_023 001_001_005 #> 18 001_001_009 001_001_008 #> 19 001_001_003 001_001_012 #> 20 001_001_008 001_001_013 #> 21 001_001_024 001_001_017 #> 22 001_001_007 001_001_001 #> 23 001_001_010 001_001_023 #> 24 001_001_009 001_001_023 #> 25 001_001_018 001_001_006 #> 26 001_001_004 001_001_020 #> 27 001_001_014 001_001_015 #> 28 001_001_016 001_001_009 #> 29 001_001_011 001_001_015 #> 30 001_001_015 001_001_015 #> 31 001_001_018 001_001_018 #> 32 001_001_014 001_001_014 #> 33 001_001_003 001_001_003 #> 34 001_001_017 001_001_017 #> 35 001_001_021 001_001_021 #> 36 001_001_011 001_001_011 #> 37 001_001_005 001_001_005 #> 38 001_001_019 001_001_019 #> 39 001_001_023 001_001_023 #> 40 001_001_024 001_001_024 #> 41 001_001_009 001_001_009 #> 42 001_001_008 001_001_008 #> 43 001_001_007 001_001_007 #> 44 001_001_010 001_001_010 #> 45 001_001_004 001_001_004 #> 46 001_001_016 001_001_016
# Numeric for only the origin locations get_unique_ids(travel_data_sim, dest=FALSE, name_class='numeric')
#> orig_id #> 1 001_001_010 #> 2 001_001_013 #> 3 001_001_009 #> 4 001_001_001 #> 5 001_001_012 #> 6 001_001_015 #> 7 001_001_008 #> 8 001_001_003 #> 9 001_001_014 #> 10 001_001_009 #> 11 001_001_015 #> 12 001_001_016 #> 13 001_001_017 #> 14 001_001_003 #> 15 001_001_013 #> 16 001_001_016 #> 17 001_001_016 #> 18 001_001_006 #> 19 001_001_001 #> 20 001_001_005 #> 21 001_001_017 #> 22 001_001_004 #> 23 001_001_007 #> 24 001_001_006 #> 25 001_001_013 #> 26 001_001_002 #> 27 001_001_009 #> 28 001_001_011 #> 29 001_001_008 #> 30 001_001_010 #> 31 001_001_013 #> 32 001_001_009 #> 33 001_001_001 #> 34 001_001_012 #> 35 001_001_015 #> 36 001_001_008 #> 37 001_001_003 #> 38 001_001_014 #> 39 001_001_016 #> 40 001_001_017 #> 41 001_001_006 #> 42 001_001_005 #> 43 001_001_004 #> 44 001_001_007 #> 45 001_001_002 #> 46 001_001_011