get_recorddataadditional: Download structuredDataRecordsAdditional data from the UNPD...

Description Usage Arguments Details Examples

View source: R/GetInformation.R

Description

Download structuredDataRecordsAdditional data from the UNPD portal

Usage

1
2
3
4
5
6
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):

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:

Examples

 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
42
43
44
45
46
47
48
49
50
51
52
## Not run: 

# You can do pretty much all queries you would do with get_recorddata:
Y <- get_recorddata(
  dataProcessTypeIds = "Census",
  indicatorTypeIds = 8, # and support numeric of string names
  locIds = "egypt", # all arguments are case insensitive
  locAreaTypeIds = "Whole area",
  subGroupIds = "Total or All groups",
  isComplete = "Abridged"
)


# But there's additional parameters such as dataTypeGroupIds or
dataTypeGroupId2s:
dt <-
  get_recorddataadditional(
    dataTypeGroupIds = "Direct", # or 3
    indicatorTypeIds = 8,
    isComplete = 0,
    locIds = 818,
    locAreaTypeIds = 2,
    subGroupIds = 2
  )


dt <-
  get_recorddataadditional(
    dataTypeGroupId2s = "Population (sample tabulation)", # or 11
    indicatorTypeIds = 8,
    isComplete = 0,
    locIds = 818,
    locAreaTypeIds = 2,
    subGroupIds = 2
  )


# Also collapse Name-ID pairs
dt <-
  get_recorddataadditional(
    dataTypeGroupId2s = "Population (sample tabulation)", # or 11
    indicatorTypeIds = 8,
    isComplete = 0,
    locIds = 818,
    locAreaTypeIds = 2,
    subGroupIds = 2,
    collapse_name_id = TRUE
  )

head(dt[, c("IndicatorName", "LocTypeName")])

## End(Not run)

timriffe/DDSQLtools documentation built on Oct. 6, 2021, 5:34 p.m.