Learn R Programming

scf (version 1.0.4)

scf_design: Construct SCF Core Data Object

Description

Stores SCF microdata as five implicate-specific designs created by survey::svrepdesign(). Raw implicate data frames are not retained.

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

Wrap a list of replicate-weighted survey designs into an "scf_mi_survey". Typically called by scf_load().

See Also

scf_load(), scf_update()

Examples

Run this code
# Do not implement these lines in real analysis:
# Use functions `scf_download()` and `scf_load()`
td  <- tempdir()
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 for real analysis: 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)

# Do not implement these lines in real analysis: Cleanup for package check
unlink("scf2022.rds", force = TRUE)

Run the code above in your browser using DataLab