Skip to contents

Check the differences between the names (or codes) given in input and the corresponding names (or codes), as provided by ISTAT, of the selected Italian statistical unit.

Usage

checkNamesIT(id,
             unit = c("ripartizione", "regione", "provincia","comune"),
             year = c("2021","2020", "2019", "2018", "2017"),
             matchWith = c("name", "code", "number"),
             return_logical = FALSE, print = TRUE, use_internet = TRUE)

Arguments

id

character vector with names or codes

unit

the type of Italian statistical unit to check

year

year of the analysis

matchWith

the type of id to check:

"name"if unit names
"code"if unit code
"number"if unit number code
return_logical

a logical value indicating whether nomatched id are returned

print

a logical value indicating whether print the nomatched names

use_internet

a logical value indicating wheter the coordinates are downloaded from https://github.com/mappinguniverse/geospatial. If FALSE the maps downloaded during package installation will be used.

Details

The function provides a check between id name or code in the dataset and the corresponding selected Italian statistical unit. unit starts from the largest aggregate, "ripartizione", to the smallest, "comune". Since unit can change over the years, the year of the data has to be provided.

Value

Returns a string vector with nomatched names or a boolean vector indicating whether or not the id matched.

Author

Alessio Serafini

Examples

data("popIT")
ck <- checkNamesIT(popIT$ID, unit = "provincia")
#> Warning: No match found for variables:  reggio di calabriaNo match found for variables:  bolzano / bozenNo match found for variables:  valle d'aosta / vallée d'aoste
str(ck)
#>  chr [1:3] "reggio di calabria" "bolzano / bozen" ...

# \donttest{
ck <- checkNamesIT(popIT$ID, unit = "provincia", return_logical = TRUE)
#> Warning: No match found for variables:  reggio di calabriaNo match found for variables:  bolzano / bozenNo match found for variables:  valle d'aosta / vallée d'aoste
str(ck)
#>  logi [1:107] TRUE TRUE TRUE TRUE TRUE TRUE ...
# }