Skip to contents

An R6 class that handles persistent or in-memory caching of data used in the Countdown 2030 analysis and reporting workflows. It supports tracking of various internal data objects, reactive updates (for Shiny apps), note-taking for report annotations, and saving/loading from .rds files.

Format

An R6::R6Class generator object.

Active bindings

cache_path

Get cache path.

countdown_data

Get countdown data.

country

Get country name.

country_iso

Get country ISO3 code.

adjusted_data

Gets adjusted data.

data_with_excluded_years

Get data with excluded years removed.

performance_threshold

Gets performance threshold.

excluded_years

Gets excluded years.

k_factors

Gets k-factors.

adjusted_flag

Gets adjusted flag.

survey_estimates

Gets survey estimates.

national_estimates

Gets national estimates.

start_survey_year

Gets start survey year.

denominator

Gets denominator.

selected_admin_level_1

Gets selected region.

selected_district

Gets selected district.

mapping_years

Gets mapping years.

un_estimates

Gets UN estimates.

wuenic_estimates

Gets WUENIC estimates.

national_survey

Gets national survey.

regional_survey

Gets regional survey.

wiq_survey

Gets WIQ survey.

area_survey

Gets area survey.

education_survey

Gets education survey.

survey_mapping

Gets survey mapping.

map_mapping

Gets map mapping. Update a field (with change tracking)

Methods


Method new()

Initialize a CacheConnection instance.

Usage

CacheConnection$new(rds_path = NULL, countdown_data = NULL)

Arguments

rds_path

Path to the RDS file (can be NULL).

countdown_data

Countdown data of class cd_data. Load data from disk.


Method load_from_disk()

Usage

CacheConnection$load_from_disk()

Returns

None. Updates internal state. Save data to disk (only if changed and RDS path is not NULL)


Method save_to_disk()

Usage

CacheConnection$save_to_disk()

Returns

None. Updates file.


Method append_page_note()

Append a note to a page.

Usage

CacheConnection$append_page_note(
  page_id,
  object_id,
  note,
  parameters = list(),
  include_in_report = FALSE,
  include_plot_table = FALSE,
  single_entry = FALSE
)

Arguments

page_id

Page ID.

object_id

Object ID.

note

Note text.

parameters

Named list of parameters.

include_in_report

Logical flag.

include_plot_table

Logical flag.

single_entry

Logical flag for uniqueness.


Method get_notes()

Retrieve notes for a given page/object.

Usage

CacheConnection$get_notes(page_id, object_id = NULL, parameters = NULL)

Arguments

page_id

Page ID.

object_id

Object ID.

parameters

Named list of parameters.


Method reactive()

Return a reactive wrapper (for Shiny).

Usage

CacheConnection$reactive()


Method set_cache_path()

Set cache RDS file path.

Usage

CacheConnection$set_cache_path(value)

Arguments

value

New file path.


Method set_countdown_data()

Set the countdown data.

Usage

CacheConnection$set_countdown_data(value)

Arguments

value

A cd_data object.


Method set_adjusted_data()

Set adjusted data.

Usage

CacheConnection$set_adjusted_data(value)

Arguments

value

A cd_data object.


Method set_performance_threshold()

Set performance threshold.

Usage

CacheConnection$set_performance_threshold(value)

Arguments

value

A numeric scalar.


Method set_excluded_years()

Set years to exclude.

Usage

CacheConnection$set_excluded_years(value)

Arguments

value

Numeric vector.


Method set_k_factors()

Set K-factors.

Usage

CacheConnection$set_k_factors(value)

Arguments

value

Named numeric vector.


Method set_adjusted_flag()

Set adjusted flag.

Usage

CacheConnection$set_adjusted_flag(value)

Arguments

value

Logical scalar.


Method set_survey_estimates()

Set survey estimates.

Usage

CacheConnection$set_survey_estimates(value)

Arguments

value

Named numeric vector.


Method set_national_estimates()

Set national estimates.

Usage

CacheConnection$set_national_estimates(value)

Arguments

value

Named list.


Method set_start_survey_year()

Set start year of surveys.

Usage

CacheConnection$set_start_survey_year(value)

Arguments

value

Integer year.


Method set_denominator()

Set denominator type.

Usage

CacheConnection$set_denominator(value)

Arguments

value

Character scalar.


Method set_selected_admin_level_1()

Set selected region.

Usage

CacheConnection$set_selected_admin_level_1(value)

Arguments

value

Character scalar.


Method set_selected_district()

Set selected district.

Usage

CacheConnection$set_selected_district(value)

Arguments

value

Character scalar.


Method set_mapping_years()

Set mapping years.

Usage

CacheConnection$set_mapping_years(value)

Arguments

value

Integer vector.


Method set_un_estimates()

Set UN estimates.

Usage

CacheConnection$set_un_estimates(value)

Arguments

value

Data frame.


Method set_wuenic_estimates()

Set WUENIC estimates.

Usage

CacheConnection$set_wuenic_estimates(value)

Arguments

value

Data frame.


Method set_national_survey()

Set national survey.

Usage

CacheConnection$set_national_survey(value)

Arguments

value

Data frame.


Method set_regional_survey()

Set regional survey.

Usage

CacheConnection$set_regional_survey(value)

Arguments

value

Data frame.


Method set_wiq_survey()

Set WIQ survey.

Usage

CacheConnection$set_wiq_survey(value)

Arguments

value

Data frame.


Method set_area_survey()

Set area-level survey.

Usage

CacheConnection$set_area_survey(value)

Arguments

value

Data frame.


Method set_education_survey()

Set education-level survey.

Usage

CacheConnection$set_education_survey(value)

Arguments

value

Data frame.


Method set_survey_mapping()

Set survey mapping table.

Usage

CacheConnection$set_survey_mapping(value)

Arguments

value

Data frame.


Method set_map_mapping()

Set map overlay mapping.

Usage

CacheConnection$set_map_mapping(value)

Arguments

value

Data frame.


Method clone()

The objects of this class are cloneable with this method.

Usage

CacheConnection$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.