R/set_return_fields.R

Defines functions set_return_fields

Documented in set_return_fields

#' Set return fields for DHS API
#'
#' \code{set_return_fields} captures a set of return fields for use in \code{fetch_data}.
#' @param dhs_return_fields Input return fields to populate the retrieved dataframe from the DHS API. Please see \url{https://api.dhsprogram.com/rest/dhs/data/fields} for complete list of available fields.
#' @return Captures a vector of the specified return fields.
#' @seealso \code{\link{fetch_data}}
#' @examples
#' set_return_fields(c("Indicator", "IndicatorId","CountryName", "DHS_CountryCode",
#'                     "SurveyYear", "SurveyYearLabel", "SurveyType",
#'                     "CharacteristicCategory", "CharacteristicLabel", "ByVariableLabel",
#'                     "DenominatorWeighted", "DenominatorUnweighted",
#'                     "CILow", "CIHigh", "Value"))
#' @export
set_return_fields <- function(dhs_return_fields) {
  if (!missing(dhs_return_fields)) {
    options(return_fields = stringr::str_c(dhs_return_fields, collapse = ","))
  }
  invisible(getOption("return_fields"))
}
murphy-xq/fetchdhs documentation built on May 14, 2019, 8:02 a.m.