datainfo: Summarize Sample and Event Information by Administrative...

View source: R/datainfo.R

datainfoR Documentation

Summarize Sample and Event Information by Administrative Level

Description

Computes summary statistics on the number of sampled observations, events, and unique clusters at national, admin1, and admin2 levels. The function merges the input dataset with cluster- and admin-level metadata and returns counts of samples, events, and clusters per geographic unit.

Usage

datainfo(data, cluster.info, admin.info1 = NULL, admin.info2 = NULL)

Arguments

data

A data frame containing at least the variables cluster and value. Typically the raw or processed indicator data (e.g., from getDHSdata()).

cluster.info

A list containing the element data, a data frame with cluster-level information. Must include a cluster column for merging.

admin.info1

A list containing the element data, a data frame with admin1-level identifiers and names. Must include the variable admin1.name.

admin.info2

A list containing the element data, a data frame with admin2-level identifiers and names. Must include the variable admin2.name.full.

Details

The function performs left and right joins to associate each observation in data with its cluster and administrative region. It removes rows with missing values before summarizing. For each administrative level:

  • n_samples: number of non-missing observations.

  • n_events: number of cases where value == 1.

  • n_clusters: number of distinct survey clusters.

If admin.info1 or admin.info2 is NULL, the corresponding summaries are omitted.

Value

A list with up to three data frames:

summary.ad0

National-level totals across all clusters.

summary.ad1

Admin1-level summaries (if admin.info1 provided).

summary.ad2

Admin2-level summaries (if admin.info2 provided).

Examples

## Not run: 
datainfo(
  data = data,
  cluster.info = cluster.info,
  admin.info1 = admin.info1,
  admin.info2 = admin.info2
)

## End(Not run)


surveyPrev documentation built on June 19, 2026, 5:06 p.m.