aggregate_weights: Aggregate discrete values

View source: R/aggregate_weights.R

aggregate_weightsR Documentation

Aggregate discrete values

Description

Aggregates discrete values together with their weights into a data frame or tibble.

Usage

aggregate_weights(y, weights, sum_to_one = FALSE)

Arguments

y

Vector of outcomes.

weights

Vector of weights, one for each of y. These need not sum to one, but must not be negative.

sum_to_one

Logical; should the weights be normalized to sum to 1? Default is FALSE.

Details

For a vector of outcomes y with a matching vector of weights, aggregate_weights() provides a single non-zero, non-NA weight per unique value of y.

Value

Data frame with the following columns:

  1. location: Increasing vector of unique values of y having positive weight.

  2. size: Weights corresponding to each outcome.


vincenzocoia/distionary documentation built on March 5, 2024, 3:13 a.m.