R/afrb-package.R

#' afrobarometer: Load the Merged Afrobarometer Survey Data
#'
#' The afrobarometer package automates downloading and merging the
#' Afrobarometer Survey Data into the R workspace.
#"
#' @section Afrobarometer functions:
#' There are three exported functions of the afrobarometer package:
#' \describe{
#'   \item{afrb_dir(path)}{Sets the Afrobarometer data directory to
#'   \code{path}.}
#'   \item{afrb_build(rounds, overwrite_db)}{After running \code{afrb_dir}, the
#'   function \code{afrb_build} merges available data for the survey rounds
#'   specified by the integer vector \code{rounds}.  If \code{overwrite} is \code{TRUE},
#'   the existing built data is overwritten.}
#'   \item{afrb_round(round)}{Extracts merged data for Round \code{round} from
#'   \code{build} subdirectory of \code{getOption("afrobarometer.data")} into a
#'   \code{data.frame}.}
#' }
#' Open access data is downloaded if needed.  The user is expected to manually
#' set the optional restricted access data in the \code{locations} subdirectory
#' of the Afrobarometer data directory, \code{getOption("afrobarometer.data")},
#' such as spatial locations of survey respondents.
#'
#' @examples
#' \dontrun{
#' 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)
#' }
#'
#'
#' @docType package
#' @name afrobarometer
NULL
sboysel/afrobarometer documentation built on May 29, 2019, 3:24 p.m.