cynthiahqy / conformr-xmap-project

R Package for harmonising data of different classifications or aggregations into a single dataset
MIT License
7 stars 1 forks source link

Add fncs `add_weights_custom` for attaching weights to pairs #113

Open cynthiahqy opened 1 year ago

cynthiahqy commented 1 year ago

Maybe rename arguments to be closer to pivot longer? and split out the adding of weights; with add_weights_* variants that return links (3col) like:

E.g. an aggregation or recode map with unit weights:

link_list <- list(AUS = c("VIC", "NSW", "QLD"),
                         NZ = c("NTH", "STH"))
pairs_from_list(link_list, names_to = "name", values_to = "value") |>
  add_weights_unit(weights_into = "w") |>
  validate_links_as_xmap(from = value, to = name, weights = w)

This also allows for generating equal weight disaggregation maps:

pairs_from_list(link_list, names_to = "name", values_to = "value") |>
  add_weights_equal(from = name, to = value, weights_into = "w") |>
  as_xmap(from = name, to = value, weights = w)

Originally posted by @cynthiahqy in https://github.com/cynthiahqy/conformr-project/issues/66#issuecomment-1512428509