gen_vector_match: Finds all occurrences of new_vector in orig_vector

Description Usage Arguments Value Examples

View source: R/bootstrap_methods.R

Description

For each value in new_vector, we find the indices of ALL matching values in orig_vector. This means that if new_vector has duplicates, we'll duplicate the indices from orig_vector too

Usage

1
gen_vector_match(orig_vector, new_vector, current_index = vector("integer", 0))

Arguments

orig_vector

Vector to find indices from.

new_vector

Vector to match values to (from orig_vector).

current_index

Accumulator of the indices so far, for recursion.

Value

Returns a vector of indices from orig_vector that correspond to values in new_vector.

Examples

1
2
3
4
5
6
7
8
## Not run: 
    orig_vector <- c(1, 1, 2, 3, 3, 3)
    new_vector <- c(1, 2, 1)

    vector_match <- gen_vector_match(orig_vector, new_vector)
    ## testthat::expect_equal(vector_match, c(1, 2, 3, 1, 2))

## End(Not run)

glmmboot documentation built on June 28, 2021, 1:05 a.m.