Skip to contents

This is an internal function used by calculate_covariance for bootstrapping data that may be either in wide format (i.e. one row per individual) or long format (i.e. one row per study visit per individual). This function takes in a list of resampled IDs, retrieves all rows of data corresponding to these IDs, and creates a unique ID that preserves the nesting structure of long format of data.

Usage

relabel_by_id(data, ids, resample = FALSE, convert_id_to_factor = TRUE)

Arguments

data

A data.frame to be resampled, which must contain a column named .id which uniquely identifies all rows corresponding to an individual.

ids

a vector of IDs that have already been resampled from data

resample

Logical scalar: Should the IDs be resampled for computing a bootstrap replicate from a list of unique IDs?

convert_id_to_factor

Logical scalar: Should the ID column be converted to a factor?

Value

A data.frame containing the resampled data with unique values of .id.

Details

The original data must have a column named .id that identifies which rows of data belong to an individual. A new value of .id is created in the resulting data, preserving the nesting structure in long data.

Examples

# To be added