@@ -125,6 +125,9 @@ du.check.variables <- function(dict_kind, data_columns, run_mode) {
125
125
# ' @noRd
126
126
du.check.nas <- function (stripped , raw ) {
127
127
128
+ # remove child_id
129
+ raw <- raw [- 1 ]
130
+
128
131
variables_na <- raw [! (raw %in% stripped )]
129
132
130
133
if (length(variables_na ) > 0 ) {
@@ -208,14 +211,15 @@ du.reshape.generate.yearly.repeated <- function(data, dict_kind) {
208
211
long_1 <- yearly_repeated_measures %> % gather(orig_var , value , matched_columns [matched_columns !=
209
212
" child_id" ], na.rm = TRUE )
210
213
211
- du.check.nas(colnames(long_1 ), colnames(yearly_repeated_measures ))
212
-
213
214
# Create the age_years variable with the regular expression extraction of the year
214
215
long_1 $ age_years <- as.numeric(du.num.extract(long_1 $ orig_var ))
215
216
216
217
# Here we remove the year indicator from the original variable name
217
218
long_1 $ variable_trunc <- gsub(" [[:digit:]]+$" , " " , long_1 $ orig_var )
218
219
220
+ raw <- unique(gsub(" [[:digit:]]+$" , " " , colnames(yearly_repeated_measures )))
221
+ du.check.nas(unique(long_1 $ variable_trunc ), raw )
222
+
219
223
# Use the maditr package for spreading the data again, as tidyverse runs into memory
220
224
# issues
221
225
long_2 <- dcast(long_1 , child_id + age_years ~ variable_trunc , value.var = " value" )
@@ -278,8 +282,6 @@ du.reshape.generate.monthly.repeated <- function(data, dict_kind) {
278
282
279
283
long_1 <- monthly_repeated_measures %> % gather(orig_var , value , matched_columns [matched_columns !=
280
284
" child_id" ], na.rm = TRUE )
281
-
282
- du.check.nas(colnames(long_1 ), colnames(monthly_repeated_measures ))
283
285
284
286
# Create the age_years and age_months variables with the regular expression
285
287
# extraction of the year
@@ -289,6 +291,9 @@ du.reshape.generate.monthly.repeated <- function(data, dict_kind) {
289
291
# Here we remove the year indicator from the original variable name
290
292
long_1 $ variable_trunc <- gsub(" [[:digit:]]+$" , " " , long_1 $ orig_var )
291
293
294
+ raw <- unique(gsub(" [[:digit:]]+$" , " " , colnames(monthly_repeated_measures )))
295
+ du.check.nas(unique(long_1 $ variable_trunc ), raw )
296
+
292
297
# Use the maditr package for spreading the data again, as tidyverse ruins into memory
293
298
# issues
294
299
long_2 <- dcast(long_1 , child_id + age_years + age_months ~ variable_trunc , value.var = " value" )
@@ -352,8 +357,6 @@ du.reshape.generate.weekly.repeated <- function(data, dict_kind) {
352
357
long_1 <- weekly_repeated_measures %> % gather(orig_var , value , matched_columns [matched_columns !=
353
358
" child_id" ], na.rm = TRUE )
354
359
355
- du.check.nas(colnames(long_1 ), colnames(weekly_repeated_measures ))
356
-
357
360
# Create the age_years and age_months variables with the regular expression
358
361
# extraction of the year NB - these weekly dta are pregnancy related so child is NOT
359
362
# BORN YET ---
@@ -362,6 +365,9 @@ du.reshape.generate.weekly.repeated <- function(data, dict_kind) {
362
365
363
366
# Here we remove the year indicator from the original variable name
364
367
long_1 $ variable_trunc <- gsub(" [[:digit:]]+$" , " " , long_1 $ orig_var )
368
+
369
+ raw <- unique(gsub(" [[:digit:]]+$" , " " , colnames(weekly_repeated_measures )))
370
+ du.check.nas(unique(long_1 $ variable_trunc ), raw )
365
371
366
372
# Use the maditr package for spreading the data again, as tidyverse ruins into memory
367
373
# issues
@@ -429,15 +435,16 @@ du.reshape.generate.trimesterly.repeated <- function(data, dict_kind) {
429
435
430
436
long_1 <- trimesterly_repeated_measures %> % gather(orig_var , value , matched_columns [matched_columns !=
431
437
" child_id" ], na.rm = TRUE )
432
-
433
- du.check.nas(colnames(long_1 ), colnames(trimesterly_repeated_measures ))
434
438
435
439
# Create the age_years and age_months variables with the regular expression
436
440
# extraction of the year
437
441
long_1 $ age_trimester <- as.numeric(du.num.extract(long_1 $ orig_var ))
438
442
439
443
# Here we remove the year indicator from the original variable name
440
444
long_1 $ variable_trunc <- gsub(" [[:digit:]]+$" , " " , long_1 $ orig_var )
445
+
446
+ raw <- unique(gsub(" [[:digit:]]+$" , " " , colnames(trimesterly_repeated_measures )))
447
+ du.check.nas(unique(long_1 $ variable_trunc ), raw )
441
448
442
449
# Use the maditr package for spreading the data again, as tidyverse ruins into memory
443
450
# issues
0 commit comments