Closed liud4 closed 11 months ago
https://github.com/liud4/rVMAP/blob/b77281077f964749d450d66ab5370c84ff6d2658/inst/rmarkdown/templates/data_merge/skeleton/skeleton.Rmd#L812
If we will copy down all variables, then use the following code with modifications
questionnaires_temp04.df[questionnaires_temp04.df$epoch %in% c(0, 1), ] <- questionnaires_temp04.df[questionnaires_temp04.df$epoch %in% c(0, 1), ] %>% group_by( map_id ) %>% tidyr::fill( setdiff(names(questionnaires_temp04.df), c("vmac_id", "redcap_event_name", "map_id", "epoch")), .direction = "down" ) %>% ungroup()
If we will (or will not) copy down selected variables from some forms, we will use this code with modifications
forms_to_pull_down_from_eligibility.var <- c("informant_information", "map_interview_form_cognitive_changes", "map_interview_form_medical_history", "functional_activities_questionnaire", "family_history", "cdr_informant", "cdr_participant", "interview_summary", "diagnosis") vars_to_pull_down_from_eligibility.var <- MAPfreeze.list$vmap_edc$metadata %>% filter( form_name %in% forms_to_pull_down_from_eligibility.var ) %>% pull( field_name ) vars_to_pull_down_from_eligibility.var <- c(vars_to_pull_down_from_eligibility.var, paste0(vars_to_pull_down_from_eligibility.var, "_factor")) vars_to_pull_down_from_eligibility.var <- vars_to_pull_down_from_eligibility.var[vars_to_pull_down_from_eligibility.var %in% names(vmap_edc_temp04.df)] vmap_edc_temp04.df[vmap_edc_temp04.df$epoch %in% c(0, 1), c("map_id", "epoch", vars_to_pull_down_from_eligibility.var)] <- vmap_edc_temp04.df[vmap_edc_temp04.df$epoch %in% c(0, 1), c("map_id", "epoch", vars_to_pull_down_from_eligibility.var)] %>% group_by( map_id ) %>% tidyr::fill( all_of(vars_to_pull_down_from_eligibility.var), .direction = "down" ) %>% ungroup()
https://github.com/liud4/rVMAP/blob/b77281077f964749d450d66ab5370c84ff6d2658/inst/rmarkdown/templates/data_merge/skeleton/skeleton.Rmd#L812
If we will copy down all variables, then use the following code with modifications
If we will (or will not) copy down selected variables from some forms, we will use this code with modifications