Crate cimdea

Source
Expand description

§CIMDEA: Convenient IPUMS Microdata Extraction and Aggregation

§Computing a Tabulation

To compute a tabulation, cimdea requires a request and a context. The tabulation request defines the tabulation by specifying which variables to tabulate in which datasets, how to group continuous variables into category bins, and so on. The context provides metadata required for computing the tabulation.

The simplest way to create a request and context is with the aptly named SimpleRequest. The from_names function supports creating a request from product, dataset, and variable names. from_names returns a context with loaded metadata and a SimpleRequest.

Once you have a Context and a type like SimpleRequest which implements DataRequest, you can pass them to the tabulate function to compute the tabulation which the DataRequest defines.

use cimdea::request::{DataRequest, SimpleRequest};
use cimdea::tabulate::{self, TableFormat};

// Set data_root to point to the directory with your data
let data_root = "tests/data_root/".to_string();
let (ctx, rq) = SimpleRequest::from_names(
    "usa",
    &["us2015b"],
    &["MARST"],
    None,
    None,
    Some(data_root),
).unwrap();

let tab = tabulate::tabulate(&ctx, rq).unwrap();
let json = tab.output(TableFormat::Json).unwrap();

For more complex requests which need to use features like general versions of variables, subpopulations, or category bins, please see AbacusRequest, which also implements DataRequest.

Modules§

conventions
Utilities for working with IPUMS conventions and metadata structure.
defaults
Definitions of default IPUMS values.
fixed_width
A support module for reading fixed-width IPUMS files and their layout files.
input_schema_tabulation
Models and parsing logic for incoming JSON tabulation requests.
ipums_data_model
Models for record types, record type relationships, and weights in IPUMS datasets.
ipums_metadata_model
Models for IPUMS metadata.
layout
Supports reading the “layout” metadata files from IPUMS microdata.
mderror
The cimdea error type.
query_gen
Generate queries from a DataRequest.
request
Utilities for creating and defining tabulation DataRequests.
tabulate
The high level module for executing and formatting tabulations.