R/clm__setLongModelComponentsToWide__transformExplanatoryToWide.R

Defines functions transformExplanatoryToWide

transformExplanatoryToWide <- function(modelComponents) {
  setXColToWide <- function(x) {
    tibble::as_tibble(x) %>%
      dplyr::mutate(wave = unlist(modelComponents$waves), id = unlist(modelComponents$ids)) %>%
      tidyr::pivot_wider(id_cols = id, names_from = wave, values_from = value, names_prefix = "T") %>%
      dplyr::select(-id)
  }
  wideExplanatory <- lapply(modelComponents$explanatory, setXColToWide)

  return(wideExplanatory)
}
phmpacheco-ufjf/clm documentation built on Dec. 22, 2021, 8:40 a.m.