Skip to contents

Some surveys ship several linked fixed-width files that share a respondent key (e.g. GSS cycle 16, "Aging and Social Support", 2002, whose MAIN, CG4, CG6 and CR files all join on `RECID`, with the person weight `WGHT_PER` living only in MAIN). `get_pumf()` returns the survey's primary module; `pumf_module()` returns one of its sibling modules **on the same DuckDB connection**, so the two tbls are joinable on the shared key without opening a second connection.

Usage

pumf_module(tbl, module)

Arguments

tbl

A lazy tbl returned by [get_pumf()] for a multi-module survey.

module

Name of the module to open (e.g. `"CG4"`). See the survey's registry entry for available module ids.

Value

A lazy `dplyr::tbl()` for the requested module, backed by the same connection as `tbl`.

Examples

# \donttest{
main <- get_pumf("GSS", "Cycle 16 (2002)") # primary module (MAIN), has WGHT_PER
#> GSS/Cycle 16 (2002) is a multi-module survey; you loaded the primary module. Other linked modules: CG4, CG6, CR.
#> Open one on the same connection with pumf_module(), e.g.:
#>   cg4 <- pumf_module(main, "CG4")
if (!is.null(main)) {
  cg4 <- pumf_module(main, "CG4")          # caregiving module, same connection
  dplyr::left_join(main, cg4, by = "RECID")
  close_pumf(main)
}
#> GSS/Cycle 16 (2002) modules join on 'RECID' (e.g. dplyr::inner_join(main, CG4, by = "RECID")).
# }