Package 'popdata'

Title: A Client for the UNHCR Popdata Platform
Description: Client for the UNHCR Popdata Platform <https://popdata.unhcr.org>. Allows to download popdata datasets into R.
Authors: Ahmadou Dicko [aut, cre], Hisham Galal [ctb], UNHCR [cph]
Maintainer: Ahmadou Dicko <[email protected]>
License: MIT + file LICENSE
Version: 0.4.9000
Built: 2024-10-21 04:02:20 UTC
Source: https://github.com/PopulationStatistics/popdata

Help Index


Augment data-frame with country metadata

Description

Augment data-frame with country metadata

Usage

pd_augment(data, col, prefix = NULL)

Arguments

data

tibble, dataset to augment

col

unquoted expression, column containing UNHCR code

prefix

character, string to prepend to metadata column names

Value

a tibble


Caching POPDATA downloaded files

Description

Manage cached POPDATA downloaded files

Usage

pd_cache_set_dir(path)

pd_cache_get_dir()

pd_cache_list()

pd_cache_delete(file)

pd_cache_clear()

Arguments

path

character, directory to set

file

Character, the file to delete

Details

The default cache directory is ⁠~/.cache/R/popdata⁠, but you can set your own path using pd_cache_set_dir()

Value

the cache directory

the cache directory

list of files in the cache

Examples

## Not run: 
pd_cache
## change the default cache directory
tmp <- tempdir()
pd_cache_set_dir(tmp)

## print current cache directory
pd_cache_get_dir()

## List available files in the current cache directory
pd_cache_list()

l <- pd_cache_list()[1] ## get the first file
pd_cache_delete(l) ## delete it

pd_cache_clear() ## delete all cached files

## End(Not run)

Country metadata

Description

Information on the countries covered by the UNHCR Population Statistics Reference platform.

Usage

pd_countries

Format

A data-frame with 226 rows and 15 variables:

bureau

The UNHCR bureau name.

code

The three character UNHCR code for each country (e.g. "ICO"). Note that to support the data, two non-standard codes are used for which no ISO codes are available: a. STA for Stateless; b. UKN for Unknown/other.

iso

The three character ISO code for each country (e.g. "CIV").

iso2

The two character ISO code for each country (e.g. "CI").

name

The country name.

nameOrigin

The name of the country when presented as a country of origin. Typically this is the same as the country name.

nameLong

The full country name.

nameShort

The official abbreviated country name.

nameFormal

The official country name.

nationality

The nationality of individuals from the country.

majorArea

The UNSD region.

region

The UNSD sub-region.

nameFr

The official country name in French.

majorAreaFr

The UNSD region in French.

regionFr

The UNSD sub-region in French.

Source

https://api.unhcr.org/population/v1/


Get Popdata session token

Description

Get Popdata session token

Usage

pd_login()

Clear memory cache used to memoise popdata functions

Description

Clear memory cache used to memoise popdata functions

Usage

pd_memoise_clear()

popdata

Description

R client for UNHCR popdata

Access UNHCR Popdata platform figures

Usage

popdata(
  report = c("asr", "mysr", "pf"),
  table = c("refugees", "refugeeLike", "returnees", "demographics", "idp", "rsd",
    "stateless", "oip", "other", "hostcommunity", "coo", "ppg", "specific", "as2",
    "comments"),
  year = 2022,
  quiet = getOption("popdata_quiet")
)

pd_asr(
  table = c("refugees", "refugeelike", "refugeeLike", "returnees", "demographics", "idp",
    "rsd", "stateless", "oip", "other", "hostcommunity", "hostCommunity", "as2",
    "comments"),
  year = 2022,
  quiet = getOption("popdata_quiet")
)

pd_mysr(
  table = c("refugees", "refugeeLike", "returnees", "idp", "rsd", "stateless", "other",
    "oip", "hostCommunity", "as2", "comments"),
  year = 2023,
  quiet = getOption("popdata_quiet")
)

pd_pf(
  table = c("coo", "ppg", "specific"),
  year = 2020,
  quiet = getOption("popdata_quiet")
)

Arguments

report

character, the type of report asr, mysr or pf

table

character, the indicator refugees, refugeeLike, returnees, demographics, idp, rsd, stateless, oip, other, hostcommunity, coo, ppg or specifics

year

integer, the year

quiet

logical, print message on updating session cookie or not. options(popdata_quiet = TRUE) can also be used

Value

A tibble

Author(s)

[email protected]