Download structuredDataRecordsAdditional data from the UNPD portal

get_recorddataadditional(
  save_file = FALSE,
  verbose = TRUE,
  collapse_id_name = FALSE,
  ...
)

Arguments

save_file

Logical. Choose whether or not to save the data in an external .Rdata file in the working directory. Default: FALSE.

verbose

Whether to print the translated query from strings to digits for faster queries. By default set to TRUE.

collapse_id_name

A logical to whether collapse all ID-Name columns into a single haven_labelled column. Default set to FALSE. See details for more information.

...

Other arguments that might define the path to data. All arguments accept a numeric code which is interpreted as the code of the specific product requested. Alternatively, you can supply the equivalent product name as a string which is case insensitive (see examples). Handle with care, this is important! For a list of all options available, see the parameters for each endpoint at https://popdiv.dfs.un.org/Demodata/swagger/ui/index#/

Details

get_recorddataadditional directly queries the endpoint structuredDataRecordsadditional. For a list of all options available for this endpoint, see the parameters for each endpoint at https://popdiv.dfs.un.org/Demodata/swagger/ui/index#!/StructuredData/StructuredData_GetStructuredDataRecords

get_recorddataadditional allows the user to supply string names for all arguments that have equivalent get_* functions. For example, get_iitypes for indicatorIds. The string used for all of these arguments should be the one from the column Name in the response from the get_* functions.

By default, all results exclude columns related to the uncertainty of the values requested (StandardErrorValue, ConfidenceInterval, etc...). By setting the argument includeUncertainty = TRUE, the uncertainty fields will be included in the final data frame.

Once the data is read from the API, some transformations are applied. If collapse_id_name is set to TRUE, all of these columns are merged with their exact ID pairs (such that only the Name columns are kept and their ID pair are assigned as labels):

  • Columns AreaName, DataReliabilityName, SubGroupName, DataStatusName, DataTypeName, DataTypeGroupName, IndicatorName, LocName, LocAreaTypeName, LocTypeName, ModelPatternName, ModelPatternFamilyName, PeriodGroupName, PeriodTypeName, RegName, SexName, StatisticalConceptName, SubGroupTypeName are converted to labelled factors with labelled

For an example to understand better how to exploit this feature, see the vignette section 'Identifying ID and Names of values'.

Regardless of the collapse_id_name value, these transformations are applied:

  • TimeStart and TimeEnd are returned with format 'DD/MM/YYYY'

Examples