subset_replace: Extract or Replace Parts of a 'demog_change_component_df'

subset_replaceR Documentation

Extract or Replace Parts of a demog_change_component_df

Description

These are methods for the subset operators and their companion replacement functions for objects of class demog_change_component_df. The return values differ and, importantly, subsetting and subset-replacement do not return objects of class demog_change_component_df (see “Details”).

Usage

## S3 method for class 'demog_change_component_df'
x[i, j, drop]

## S3 replacement method for class 'demog_change_component_df'
x[i, j] <- value

## S3 replacement method for class 'demog_change_component_df'
x$name <- value

## S3 replacement method for class 'demog_change_component_df'
x[[i, j]] <- value

## S3 method for class 'demog_change_component_df'
subset(x, ...)

Arguments

x

data frame.

i

elements to extract or replace. For [ and [[, these are numeric or character or, for [ only, empty or logical. Numeric values are coerced to integer as if by as.integer. For replacement by [, a logical matrix is allowed.

j

elements to extract or replace. For [ and [[, these are numeric or character or, for [ only, empty or logical. Numeric values are coerced to integer as if by as.integer. For replacement by [, a logical matrix is allowed.

drop

logical. If TRUE the result is coerced to the lowest possible dimension. The default is to drop if only one column is left, but not to drop if only one row is left.

value

A suitable replacement value: it will be repeated a whole number of times if necessary and it may be coerced: see the Coercion section. If NULL, deletes the column if a single column is selected.

name

A literal character string or a name (possibly backtick quoted).

...

elements to extract or replace. For [ and [[, these are numeric or character or, for [ only, empty or logical. Numeric values are coerced to integer as if by as.integer. For replacement by [, a logical matrix is allowed.

Details

Arbitrary subsets or modifications of demog_change_component_dfs (and objects of subclasses) may not be valid members of the class. Therefore, the object resulting from a subset operation via `[`, or a replacement via `[<-`, and similar, will no longer inherit from class demog_change_component_df (or subclasses) and the attributes specific to those classes will be lost.

To create a demog_change_component_df object from a subset call demog_change_component_df explicitly (e.g., demog_change_component_df(x[x$time_start == 1960,])). A similar approach can be taken for subset-replacement. For an alternative approach to simple subsetting on the demographic change component dimensions see subset_time and friends.

Value

A data.frame, one-dimensional vector, or scalar depending on the dimensions of the extracted values.

Author(s)

Mark Wheldon

See Also

demog_change_component_df for class definitions, link{subset_time} and friends.


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