# Do not implement these lines in real analysis:
# Use functions `scf_download()` and `scf_load()`
td <- tempfile("proptest_")
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)
# Wrangle data for example
scf2022 <- scf_update(scf2022,
rich = networth > 1e6,
female = factor(hhsex, levels = 1:2, labels = c("Male","Female")),
over50 = age > 50
)
# Example for real analysis: One-sample test
scf_prop_test(scf2022, ~rich, p = 0.10)
# Example for real analysis: Two-sample test
scf_prop_test(scf2022, ~rich, ~female, alternative = "less")
# Do not implement these lines in real analysis: Cleanup for package check
unlink(td, recursive = TRUE, force = TRUE)
Run the code above in your browser using DataLab