subset_demog_change_component_df: Subset by time, age, sex, or indicator

subset_time.death_count_age_sexR Documentation

Subset by time, age, sex, or indicator

Description

These functions subset objects inheriting from demog_change_component_df by one of the four dimensions, indicator, age, time, or sex, and retain the class if valid (see “Details”). Subsetting such that only one level of the subset dimension is retained will drop the dimension if drop = TRUE, otherwise it is retained (default). If the object returned after subsetting is a valid member of the original class it will be returned (valid according to validate_ccmppWPP_object). If it is not valid an error will be signalled and nothing is returned.

Usage

## S3 method for class 'death_count_age_sex'
subset_time(x, times, include = TRUE)

## S3 method for class 'death_count_age_sex'
subset_age(x, ages, include = TRUE)

## S3 method for class 'death_count_age_sex'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'death_probability_age_sex'
subset_time(x, times, include = TRUE)

## S3 method for class 'death_probability_age_sex'
subset_age(x, ages, include = TRUE)

## S3 method for class 'death_probability_age_sex'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'ccmpp_input_df'
subset_indicator(x, indicators, include = TRUE)

## S3 method for class 'ccmpp_input_df'
subset_time(x, times, include = TRUE)

## S3 method for class 'ccmpp_input_df'
subset_age(x, ages, include = TRUE)

## S3 method for class 'ccmpp_input_df'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'fert_rate_age_f'
subset_time(x, times, include = TRUE)

## S3 method for class 'fert_rate_age_f'
subset_age(x, ages, include = TRUE)

## S3 method for class 'life_table_age_sex'
subset_indicator(x, indicators, include = TRUE)

## S3 method for class 'life_table_age_sex'
subset_time(x, times, include = TRUE)

## S3 method for class 'life_table_age_sex'
subset_age(x, ages, include = TRUE)

## S3 method for class 'life_table_age_sex'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'mig_net_count_age_sex'
subset_time(x, times, include = TRUE)

## S3 method for class 'mig_net_count_age_sex'
subset_age(x, ages, include = TRUE)

## S3 method for class 'mig_net_count_age_sex'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'mig_net_count_tot_b'
subset_time(x, times, include = TRUE)

## S3 method for class 'mig_net_rate_age_sex'
subset_time(x, times, include = TRUE)

## S3 method for class 'mig_net_rate_age_sex'
subset_age(x, ages, include = TRUE)

## S3 method for class 'mig_net_rate_age_sex'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'mig_parameter'
subset_time(x, times, include = TRUE)

## S3 method for class 'mig_parameter'
subset_indicator(x, times, include = TRUE)

## S3 method for class 'mort_rate_age_sex'
subset_time(x, times, include = TRUE)

## S3 method for class 'mort_rate_age_sex'
subset_age(x, ages, include = TRUE)

## S3 method for class 'mort_rate_age_sex'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'pop_count_age_sex_base'
subset_time(x, times, include = TRUE)

## S3 method for class 'pop_count_age_sex_base'
subset_age(x, ages, include = TRUE)

## S3 method for class 'pop_count_age_sex_base'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'srb'
subset_time(x, times, include = TRUE)

## S3 method for class 'survival_ratio_age_sex'
subset_time(x, times, include = TRUE)

## S3 method for class 'survival_ratio_age_sex'
subset_age(x, ages, include = TRUE)

## S3 method for class 'survival_ratio_age_sex'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'ccmpp_output_df'
subset_indicator(x, indicators, include = TRUE)

## S3 method for class 'ccmpp_output_df'
subset_time(x, times, include = TRUE)

## S3 method for class 'ccmpp_output_df'
subset_age(x, ages, include = TRUE)

## S3 method for class 'ccmpp_output_df'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'pop_count_age_sex'
subset_time(x, times, include = TRUE)

## S3 method for class 'pop_count_age_sex'
subset_age(x, ages, include = TRUE)

## S3 method for class 'pop_count_age_sex'
subset_sex(x, sexes, include = TRUE)

## S3 method for class 'pop_count_age_sex_reference'
subset_time(x, times, include = TRUE)

## S3 method for class 'pop_count_age_sex_reference'
subset_age(x, ages, include = TRUE)

## S3 method for class 'pop_count_age_sex_reference'
subset_sex(x, sexes, include = TRUE)

subset_time(x, times, include = TRUE, ...)

## S3 method for class 'demog_change_component_df'
subset_time(x, times, include = TRUE, drop = FALSE)

subset_age(x, ages, include = TRUE, ...)

## S3 method for class 'demog_change_component_df'
subset_age(x, ages, include = TRUE, drop = FALSE)

subset_sex(x, sexes, include = TRUE, ...)

## S3 method for class 'demog_change_component_df'
subset_sex(x, sexes = get_all_allowed_sexes(), include = TRUE, drop = FALSE)

subset_indicator(x, indicators, include = TRUE, ...)

## S3 method for class 'demog_change_component_df'
subset_indicator(x, indicators, include = TRUE, drop = FALSE)

Arguments

x

An object to subset.

include

Logical; should the rows corresponding to the values supplied in the previous argument be those that are kept or discarded?

indicators, times, ages, sexes

Vectors indicating the levels of time, age, or sex to retain (include = TRUE) or exclude (include = FALSE). ages and times are coerced to numeric via as.numeric.

drop

Logical; should demographic change component dimensions with only one level be dropped? Not available in all methods; see “Details”.

Details

For subset_times and subset_ages rows can be excluded by supplying negative times or ages. In that case, all values must be negative and include must be TRUE (the default). Violations will result in an error.

Argument drop is not available in the methods for objects inheriting from ccmpp_input_df because these objects must have (and keep) the set of dimensions specified in their class definition. E.g., fert_rate_input objects may be subset by time, but the time dimension cannot be dropped because objects of this class must always have a time dimension.

Value

The object after subsetting if a valid member of the class; otherwise an error.

Note on efficiency

These functions are not particularly efficient. For repeated subsetting within, e.g., a for loop, it is better to use standard subsetting operations on the data frame component and re-cast the result as a classed object at the end if desired.

Author(s)

Mark Wheldon

See Also

Other subset_by_demographic_dimension: subset_ccmpp_input_list


markalava/ccmppWPP documentation built on April 21, 2022, 12:36 a.m.