afrobarometer: afrobarometer: Load the Merged Afrobarometer Survey Data

Description Afrobarometer functions Examples

Description

The afrobarometer package automates downloading and merging the Afrobarometer Survey Data into the R workspace.

Afrobarometer functions

There are three exported functions of the afrobarometer package:

afrb_dir(path)

Sets the Afrobarometer data directory to path.

afrb_build(rounds, overwrite_db)

After running afrb_dir, the function afrb_build merges available data for the survey rounds specified by the integer vector rounds. If overwrite is TRUE, the existing built data is overwritten.

afrb_round(round)

Extracts merged data for Round round from build subdirectory of getOption("afrobarometer.data") into a data.frame.

Open access data is downloaded if needed. The user is expected to manually set the optional restricted access data in the locations subdirectory of the Afrobarometer data directory, getOption("afrobarometer.data"), such as spatial locations of survey respondents.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
library(afrobarometer)
afrb_dir(path = "~/foo")
# download first 3 rounds but do not overwrite the existing database.
# This will fail if the database has already been built.
afrb_build(rounds = 3:4)
# download all rounds (rounds 1 through 6) and overwrite the existing database.
afrb_build(rounds = 3:4, overwrite = TRUE)
# load round 4 from the database into a data.frame
afrb4 <- afrb_round(4)

## End(Not run)

sboysel/afrobarometer documentation built on May 29, 2019, 3:24 p.m.