Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

which.weight

Sample an index of a vector weighted by the elements


Description

Returns a random index, weighted by the element magnitudes. This function is intended to be used as an optional strategy for trajectoryAssignments, resulting in randomly sampled cluster membership.

Usage

which.weight(x)

Arguments

x

A positive numeric vector.

Value

An integer giving the index of the sampled element.

Examples

x = c(.01, .69, .3)
which.weight(x) #1, 2, or 3

latrend

A Framework for Clustering Longitudinal Data

v1.1.2
GPL (>= 2)
Authors
Niek Den Teuling [aut, cre] (<https://orcid.org/0000-0003-1026-5080>), Steffen Pauws [ctb], Edwin van den Heuvel [ctb], Copyright © 2021 Koninklijke Philips N.V. [cph]
Initial release
2021-04-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.