country_attribution: Functions to improve the country attribution in a...

Description Usage Arguments Value Examples

Description

c14bazAAR provides several functions to check and improve the spatial attribution of the individual dates in a c14_date_list to a country.

c14bazAAR::standardize_country_name() adds column country_thes with standardized country names. Most source databases come with a column country that contains a character name of the origin country for each date. Unfortunately the different source databases don't rely on a unified naming convention and therefore use various terms to represent the same country (for example: United Kingdom, Great Britain, GB, etc.). This function aims to standardize the country naming scheme. To achieve this, it compares the names to values in an external (countrycode::codelist) and an internal country_thesaurus reference list. The latter needs manual curation to catch semantic and spelling errors in the source databases.

c14bazAAR::determine_country_by_coordinate() adds the column country_coord with standardized country attribution based on the coordinate information of the dates. Due to the inconsistencies in the country column in many c14 source databases it's often necessary to rely on the coordinate position (lat & lon) for reliable country attribution information.

finalize_country_name() picks the country name in a hierarchical order from the results of c14bazAAR::determine_country_by_coordinate() and c14bazAAR::standardize_country_name() functions, followed by the original input of the database. The result is added to the input date list with the column country_final.

finalize_country_name() also calls the other functions c14bazAAR::determine_country_by_coordinate() and c14bazAAR::standardize_country_name() if the necessary columns are missing yet.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
determine_country_by_coordinate(x, suppress_spatial_warnings = TRUE)

## Default S3 method:
determine_country_by_coordinate(x, suppress_spatial_warnings = TRUE)

## S3 method for class 'c14_date_list'
determine_country_by_coordinate(x, suppress_spatial_warnings = TRUE)

finalize_country_name(x, quiet = FALSE)

## Default S3 method:
finalize_country_name(x, quiet = FALSE)

## S3 method for class 'c14_date_list'
finalize_country_name(x, quiet = FALSE)

standardize_country_name(
  x,
  country_thesaurus = get_country_thesaurus(),
  codesets = c("country.name.de", "iso3c"),
  quiet = FALSE,
  ...
)

## Default S3 method:
standardize_country_name(
  x,
  country_thesaurus = get_country_thesaurus(),
  codesets = c("country.name.de", "iso3c"),
  quiet = FALSE,
  ...
)

## S3 method for class 'c14_date_list'
standardize_country_name(
  x,
  country_thesaurus = get_country_thesaurus(),
  codesets = c("country.name.de", "iso3c"),
  quiet = FALSE,
  ...
)

Arguments

x

an object of class c14_date_list

suppress_spatial_warnings

suppress some spatial data messages and warnings

quiet

suppress suppress decision log output

country_thesaurus

data.frame with correct and variants of country names

codesets

which country codesets should be searched for in countrycode::codelist beyond country.name.en? See ?countrycode::codelist for more information

...

additional arguments are passed to stringdist::stringdist(). stringdist() is used for fuzzy string matching of the country names in countrycode::codelist

Value

an object of class c14_date_list with the additional columns country_thes, country_coord and/or country_final

Examples

1
2
3
4
5

c14bazAAR documentation built on March 26, 2020, 6:38 p.m.