Learn R Programming

scf (version 1.0.5)

scf_design: Construct SCF Core Data Object

Description

Stores SCF microdata as five implicate-specific designs created by survey::svrepdesign().

Usage

scf_design(design, year, n_households)

Value

An object of class "scf_mi_survey" with:

mi_design

List of replicate-weighted designs (one per implicate).

year

SCF survey year.

n_households

Estimated number of U.S. households.

Arguments

design

A list of five survey::svrepdesign() objects (one per implicate).

year

Numeric SCF survey year (e.g., 2022).

n_households

Numeric total U.S. households represented in year.

Details

This is a helper function for the scf_download() and scf_load() functions. Wrap a list of replicate-weighted survey designs into an "scf_mi_survey". Typically called by scf_load(). The function creates a complex object that includes the Survey's five implicates, along with the year and an estimate of the total U.S. households in that year.

See Also

scf_load(), scf_update()

Examples

Run this code
# Ignore this code block.  It loads mock data for CRAN.
# In your analysis, download and load your data using the
# functions `scf_download()` and `scf_load()`
td <- tempfile("design_")
dir.create(td)

src <- system.file("extdata", "scf2022_mock_raw.rds", package = "scf")
file.copy(src, file.path(td, "scf2022.rds"), overwrite = TRUE)
scf2022 <- scf_load(2022, data_directory = td)

# EXAMPLE IMPLEMENTATION: Construct scf_mi_survey object
obj <- scf_design(
  design = scf2022$mi_design,
  year = 2022,
  n_households = attr(scf2022, "n_households")
)
class(obj)
length(obj$mi_design)

# Ignore the code below.  It is for CRAN:
unlink(td, recursive = TRUE, force = TRUE)

Run the code above in your browser using DataLab