forked from vynguyen92/publish_nhanes_data_1988_2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf - check_num_cycles_documentation.R
executable file
·42 lines (37 loc) · 1.38 KB
/
f - check_num_cycles_documentation.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
check_num_cycles_documentation <- function(list_documentation
, name_of_dataset)
{
df_documentation <- list_documentation[[name_of_dataset]]
# View(df_documentation)
name_dataset_fix_cats <- paste(name_of_dataset
, "Fix Category")
df_documentation_fix_categories <- list_documentation[[name_dataset_fix_cats]]
# View(df_documentation_fix_categories)
df_doc_fix_cycles <- df_documentation_fix_categories %>%
select(codename_original
, grep("^cycle"
, colnames(.))) %>%
pivot_longer(cols = grep("^cycle"
, colnames(.))
, names_to = "SDDSRVYR"
, values_to = "value_fix_categories") %>%
mutate(SDDSRVYR = gsub("cycle_"
, ""
, SDDSRVYR)) %>%
drop_na(value_fix_categories) %>%
mutate(SDDSRVYR = as.numeric(SDDSRVYR)) %>%
rename(variable_codename = codename_original)
# View(df_doc_fix_cycles)
df_doc_cycles <- df_documentation %>%
select(variable_codename
, SDDSRVYR
, variable_codename_use) %>%
unique(.)
# View(df_doc_cycles)
df_doc_togther <- df_doc_cycles %>%
full_join(.
, df_doc_fix_cycles
, by = c("variable_codename"
, "SDDSRVYR"))
View(df_doc_togther)
}