get.country.object {bayesTFR}R Documentation

Accessing Country Information

Description

Function get.country.object returns an object containing country name, code and index. Functions get.countries.table return a data frame containing codes, names and optionally ISO character codes of all countries. Functions get.countries.phase return countries table with the TFR phase they are currently in (1, 2, or 3).

Usage

get.country.object(country, meta = NULL, country.table = NULL, index = FALSE)

## S3 method for class 'bayesTFR.mcmc.set'
get.countries.table(object, iso = FALSE, ...)
## S3 method for class 'bayesTFR.prediction'
get.countries.table(object, iso = FALSE, ...)

## S3 method for class 'bayesTFR.mcmc.set'
get.countries.phase(object, ...)
## S3 method for class 'bayesTFR.prediction'
get.countries.phase(object, ...)

Arguments

country

Country name, code or index. If it is an index, the argument index must be set to TRUE. The code can be either numeric or ISO-2 or ISO-3 characters.

meta

Object of class bayesTFR.mcmc.meta. If it is not given, the argument country.table must be given.

country.table

A table containing columns “name” and “code” from which the country info can be extracted. Only relevant, if meta is NULL.

index

Logical determining if the argument country is an index.

object

Object of class bayesTFR.mcmc.set or bayesTFR.prediction.

iso

Logical. If TRUE, two extra columns are added to the table, namely 2- and 3-characters ISO codes.

...

Not used.

Details

Given partial information about a country (i.e. having either name or code or index), the function get.country.object returns an object containing all three pieces of information. Only countries are considered that are included in the simulations and predictions. Country index is an internal index used in various components of a bayesTFR.mcmc.meta object.

Value

Function get.country.object returns a list with components:

name

Country name

code

Country numeric code

index

Country index

Function get.countries.table returns a data frame with columns code, name, and optionally (if iso is TRUE) iso2 and iso3.

Function get.countries.phase returns a data frame with columns code, name and phase.

Author(s)

Hana Sevcikova

See Also

country.names

Examples

sim.dir <- file.path(find.package("bayesTFR"), "ex-data", "bayesTFR.output")
m <- get.tfr.mcmc(sim.dir)
# all five calls should give the same answer
get.country.object('China', m$meta)
get.country.object('CN', m$meta)
get.country.object(156, m$meta)
get.country.object(56, m$meta, index=TRUE)
get.country.object(156, NULL, country.table=get.countries.table(m))

# phase 3 countries
subset(get.countries.phase(m), phase == 3)

[Package bayesTFR version 7.2-0 Index]