estimates_exist: Check whether stratum estimates already exist in...

estimates_existR Documentation

Check whether stratum estimates already exist in pre-calculated files.

Description

Check whether stratum estimates already exist in pre-calculated files.

Usage

estimates_exist(stratum_data_prepped, estimates_dir)

Arguments

stratum_data_prepped

A data frame including all records in a stratum of interest. The data frame should only include the source columns prefixed with in_ and all columns should only contain 1's and 0's.

estimates_dir

Directory containing pre-calculated estimates, if you would like to use pre-calculated results.

Value

A list with two entries, estimates_exist and estimates_path. estimates_exist is a logical value indicating whether calculations for the stratum of interest are available in the directory containing the pre-calculated estimates. If estimates_exist is TRUE, estimates_path will contain the full file path to the JSON file containing the estimates, otherwise it will be NA.

Examples


in_A <- sample(c(0, 1), size = 100, replace = TRUE, prob = c(0.45, 0.65))
in_B <- sample(c(0, 1), size = 100, replace = TRUE, prob = c(0.5, 0.5))
in_C <- sample(c(0, 1), size = 100, replace = TRUE, prob = c(0.75, 0.25))
in_D <- sample(c(0, 1), size = 100, replace = TRUE, prob = c(1, 0))

my_stratum <- tibble::tibble(in_A, in_B, in_C, in_D) %>%
    dplyr::mutate(rs = rowSums(.)) %>%
    dplyr::filter(rs >= 1) %>%
    dplyr::select(-rs)

estimates_exist(stratum_data_prepped = my_stratum, estimates_dir = "path_to_estimates")


verdata documentation built on June 8, 2025, 11:46 a.m.