Skip to contents

#' Transform year_measured Variable Based on Clustered Conditions Within Waves #' #' @param dt A `data.frame` or `data.table` in long format containing repeated measures. #' @param cluster_id A string specifying the cluster identifier variable. Default is "rel_num". #' @param id_var A string specifying the individual identifier variable. Default is "id". #' @param wave_var A string specifying the variable indicating the wave. Default is "wave". #' @param condition_var A string specifying the condition variable. Default is "rel_complete". #' @param condition_value The value of `condition_var` that triggers transformation. Default is 0. #' @param year_measured_var A string specifying the `year_measured` variable. Default is "year_measured". #' #' @return A modified `data.table` with updated year_measured values based on the condition. #' #' @import data.table #' @import cli #' @export #' Transform year_measured Variable Based on Clustered Conditions Within Waves #' #' @param dt A `data.frame` or `data.table` in long format containing repeated measures. #' @param cluster_id A string specifying the cluster identifier variable. Default is "rel_num". #' @param id_var A string specifying the individual identifier variable. Default is "id". #' @param wave_var A string specifying the variable indicating the wave. Default is "wave". #' @param condition_var A string specifying the condition variable. Default is "rel_complete". #' @param condition_value The value of `condition_var` that triggers transformation. Default is 0. #' @param year_measured_var A string specifying the `year_measured` variable. Default is "year_measured". #' #' @return A modified `data.table` with updated year_measured values based on the condition. #' #' @import data.table #' @import cli #' @export

Usage

margot_censor(
  dt,
  cluster_id = "rel_num",
  id_var = "id",
  wave_var = "wave",
  condition_var = "rel_complete",
  condition_value = 0,
  year_measured_var = "year_measured"
)