make_value_product: Calculate the product of values in two data frames

View source: R/S3_classes_demog_change_component_utility_functions.R

make_value_productR Documentation

Calculate the product of values in two data frames

Description

The product of the “value” columns in data frames x and y is calculated and returned. x and y are first merged on columns named by_vars_names and these columns are in the output, which is also a data frame.

Usage

make_value_product(x, y, by_vars_names = NULL, all.x = TRUE, all.y = FALSE)

Arguments

x, y

Data frames with columns “by_vars_names” and “value”.

by_vars_names

Character vector of names of columns to merge by. By default, all columns except “value”. See also “Details”.

all.x

logical; if TRUE, then extra rows will be added to the output, one for each row in x that has no matching row in y. These rows will have NAs in those columns that are usually filled with values from y. The default is FALSE, so that only rows with data from both x and y are included in the output.

all.y

logical; analogous to all.x.

Details

Special processing occurs when by_vars_names is NULL and either x or y has column time_span and all entries are 0. In this case, before merging, “time_span” is omitted from by_vars_names and the time_span column is dropped from y. This ensures the result has only one time_span column, namely the one from x.

Value

A data frame with columns “by_vars_names” and “value”, where the latter holds the product of “value”s in x and y.

Author(s)

Mark Wheldon


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