A few countries have changed their ISO codes over time. Usually this is because countries split or merged; occasionally it's because they just didn't like the old one. This function allows us to insert an ISO code change into a pipeline.

change_iso_code(d, from, to, col = "iso")

Arguments

d

The data to be transformed

from

The old ISO code

to

The replacement ISO code

col

The name of the columns with the ISO codes (default = 'iso')

Value

Tibble with the old iso code replaced by the new one.

Details

If you're dealing with a split or a merger, then making this change will generally create duplicate rows, so you should follow it up with an appropriate aggregation.