mergeCalSparseFrames: Merge data frames with date-sparse data

Description Usage Arguments Details Value Author(s)

View source: R/mergeCalSparseFrames.R

Description

This function merges two data frames that are created using aggregateAndFillDataGroupGaps and creates a rate with roll capability and sparse entry handling.

Usage

1
2
mergeCalSparseFrames(numFrame, denomFrame, mergeColsX, mergeColsY, numNumeric,
  denomNumeric, sparseHandling, rollPeriods = 0)

Arguments

numFrame

a sparse data frame created using the aggregateAndFillDateGroupGaps function

denomFrame

a sparse data frame created using the aggregateAndFillDateGroupGaps function

mergeColsX

a vector of character strings specifying which columns to use in the merge function's by.x parameter

mergeColsY

a vector of character strings specifying which columns to use in the merge function's by.y parameter

numNumeric

a character string that identifies which column of the numFrame contains the numeric value to use as the numerator in the rate calculation

denomNumeric

a character string that identifies which column of the denomFrame contains the numeric value to use as the denominator in the rate calculation

sparseHandling

a numeric (either NA or 0) that tells the function how to handle sparse Rate values after the merge

rollPeriods

a numeric (default = 0) that indicates the number of periods to include in the rolling rate (0, default, is not rolled)

Details

This function takes a numFrame, denomFrame, mergeColsX, mergeColsY, numNumeric, denomNumeric, sparseHandling, rollPeriods, and lagPeriods. It returns a data.frame that contains a DateGroup, columns from numFrame (less the numNumeric column), and a Rate (either rolled or not with sparse entries handled as specified by the sparseHandling parameter). The rate is calculated by merging the numFrame and denomFrame by the mergeColsX and mergeColsY and then finding a rate for each unique combination of the merged columns.

Value

a data frame that contains the orginal columns in numFrame as well as a Rate that is calculated using the numNumeric/denomNumeric and adjusted using sparseHandling for DateGroups that are sparse in the numFrame

Author(s)

Aimie Faucett


BioAimie/dateManip documentation built on May 5, 2019, 3:46 p.m.