Learn R Programming

PortfolioTesteR (version 0.1.4)

ml_panel_op: Panel-safe binary operation on aligned wide panels

Description

Applies an elementwise binary operator to two date-aligned wide panels (first column Date, other columns are symbols), preserving the Date column and a consistent symbol set. Supports intersection or union of column sets; missing entries introduced by how="union" are filled.

Usage

ml_panel_op(A, B, op = `*`, how = c("intersect", "union"), fill = NA_real_)

Value

A data.frame with Date and the operated symbol columns.

Arguments

A, B

Data frames with a Date column and one column per symbol.

op

Binary function to apply elementwise (e.g., *, /, +).

how

Character; "intersect" (default) or "union" for the set of symbol columns to operate on.

fill

Numeric; value used to fill gaps when how="union".

Examples

Run this code
if (FALSE) {
out <- ml_panel_op(mom12_panel, vol_panel, op = `*`)
}

Run the code above in your browser using DataLab