R/1.6.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)
}

Try the Mmcsd package in your browser

Any scripts or data that you put into this service are public.

Mmcsd documentation built on March 31, 2023, 7:23 p.m.