RISE_FJ/T1_child_sampling/O3_T1_FJ-corrections.R

# ####################################################
# ##            CORRECTIONS                         ##
# ## This file contains running corrections         ##
# ## to the data before any analysis was conducted. ##
# ####################################################
#
# ####################################################
#GENERAL CORRECTIONS

#some of name fields didn't work properly

#1. FIX RESPONDENT NAME IF ENTERED MANUALLY
#note: if respondent name is entered manually, there should be no pulled data for respondent_id or name
#there seems to be some kind of glitch in surveycto sometimes pulling through data - need to delete it
child$respondent_id[!is.na(child$respondent_name_first)]<-NA
child$respondent_name2[!is.na(child$respondent_name_first)]<-NA

#2. FIX CHILD NAME IF ENTERED MANUALLY
#note: if respondent name is entered manually, there should be no pulled data for respondent_id or name
#there seems to be some kind of glitch in surveycto sometimes pulling through data - need to delete it
child$child_id_pl[!is.na(child$child_name_first)]<-NA
child$child_name2[!is.na(child$child_name_first)]<-NA

# ####################################################
#check for duplicate surveys

dup_child <- child %>% 
  filter (!is.na(child_name)) %>% 
  mutate(id = paste0(settlement_barcode, extract_house_no, hhd_id, child_dob))
table(duplicated(dup_child$id)) #39 dup
x <- dup_child[duplicated(dup_child$id),] %>% #only  duplicates, excluding NA
  select (settlement_barcode, extract_house_no, hhd_id, child_dob, child_name, today, id, 
          survey_check2, cough, feces_check2, height_check2, blood_check2)
y <- child %>% 
  select (settlement_barcode, extract_house_no, hhd_id, child_dob, child_name, today, 
          survey_check2, cough, 
          feces_check2, feces_kit_barcode, feces_kit_barcode_note,
          height_check2, weight_yn, height_yn2, 
          blood_check2, edta_yn, serum_yn, blood_hb_yn, blood_spot_no)

#Kinoya #9 - 3 surveys for same child; 2 health surveys done; 1 feces kit, 2 anthro; no blood
#Kinoya #19 - no duplication
#Kinoya #23 - no duplication
#Kinoya #48 - no duplication
#kinoya #66 - no duplication
#ACTION: I will need to check for survey duplication in all data ****** - will have to be dealt with by item (survey, anthro, blood, etc.)

rm(dup_child, x, y)
# ####################################################

# ####################################################
# ####################################################
#SETTLEMENT-SPECIFIC CORRECTIONS
# # FIXES and their descriptions can be found here:
# # https://docs.google.com/spreadsheets/d/1O31YAYQ8ZeC0_myg2JiLvZrGyhTZdKh4k6nk6eSJvOU/edit#gid=884184821
#

# ####################################################
# # Kinoya #
#
# #house #09 did not receive a feces kit. Feces kit F-F0-000119 should only be
# #associated with house #015 - Jeff Fine
child$feces_kit_barcode [child$feces_kit_barcode == "F-F0-000119" &
                                        child$settlement_barcode == "Kinoya" &
                                        child$extract_house_no == "9" &
                                        child$child_id_pl== "54280" &
                                        child$child_dob == "2019-06-09" & child$child_gender == "male"] <- NA

# #house #07 did not receive a feces kit. Feces kit F-F0-000027 should only be
# #associated with house #67 - Jeff Fine
feces$barcode_scan_text [feces$barcode_scan_text == "FK-HH-007" &
                           feces$settlement_barcode == "Kinoya" &
                           feces$extract_house_no == "7" &
                           feces$KEY == "uuid:c44992d8-a046-4fd8-b3ff-59c06a83c126"] <- "FK-HH-067"
feces$extract_house_no [feces$barcode_scan_text == "FK-HH-067" &
                           feces$settlement_barcode == "Kinoya" &
                           feces$extract_house_no == "7" &
                           feces$KEY == "uuid:c44992d8-a046-4fd8-b3ff-59c06a83c126"] <- 67

# #house #07 did not receive a feces kit. Feces kit F-F0-000498 should only be
# #associated with house #67 - Jeff Fine
feces$barcode_scan_text [feces$barcode_scan_text == "FK-HH-007" &
                           feces$settlement_barcode == "Kinoya" &
                           feces$extract_house_no == "7" &
                           feces$KEY == "uuid:065aa6a1-68b8-4939-a18c-7223b0f990d5"] <- "FK-HH-067"
feces$extract_house_no [feces$barcode_scan_text == "FK-HH-067" &
                          feces$settlement_barcode == "Kinoya" &
                          feces$extract_house_no == "7" &
                          feces$KEY == "uuid:065aa6a1-68b8-4939-a18c-7223b0f990d5"] <- 67

# #house #15 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2016-10-30" &
                          child$settlement_barcode == "Kinoya" &
                          child$extract_house_no == "15" &
                          child$child_id_pl == "54011" &
                          child$child_gender == "male" &
                          (child$barcode_scan == "FK-HH-015" | child$barcode_scan_text == "FK-HH-015")] <- "2015-09-30"

# #house #90 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2017-03-01" &
                   child$settlement_barcode == "Kinoya" &
                   child$extract_house_no == "90" &
                   child$child_id_pl == "54040" &
                   child$child_gender == "female" &
                   (child$barcode_scan == "FK-HH-090" | child$barcode_scan_text == "FK-HH-090")] <- "2017-06-16"

# #house #93 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2018-06-18" &
                   child$settlement_barcode == "Kinoya" &
                   child$extract_house_no == "93" &
                   child$child_id_pl == "54162" &
                   child$child_gender == "male" &
                   (child$barcode_scan == "FK-HH-093" | child$barcode_scan_text == "FK-HH-093")] <- "2018-01-31"

#
# ####################################################
# # Maravu #
#
# #house #14 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2015-09-20" &
                   child$settlement_barcode == "Maravu" &
                   child$extract_house_no == "14" &
                   child$child_id_pl == "53888" &
                   child$child_gender == "female" &
                   (child$barcode_scan == "FL-HH-014" | child$barcode_scan_text == "FL-HH-014")] <- "2015-08-20"

#
# ####################################################
# # Wainivokai #
#
# #house #20 survey_status = 1 should be survey_status = 7 as family has refused
# #to participate in the study - Jeff Fine (14/10/2019)
child$survey_status [child$survey_status == 1 &
                   child$settlement_barcode == "Wainivokai" &
                   child$extract_house_no == "20" &
                   child$child_id_pl == "54217" &
                   child$child_gender == "male"] <- 7

# #house #10 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2018-01-29" &
                   child$settlement_barcode == "Wainivokai" &
                   child$extract_house_no == "10" &
                   child$child_id_pl == "54119" &
                   child$child_gender == "female" &
                   (child$barcode_scan == "FA-HH-010" | child$barcode_scan_text == "FA-HH-010")] <- "2018-01-31"

#
# ####################################################
# # Wailea #
#
# #house #75 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2014-11-22" &
                   child$settlement_barcode == "Wailea" &
                   child$extract_house_no == "75" &
                   child$child_id_pl == "53781" &
                   child$child_gender == "male" &
                   (child$barcode_scan == "FG-HH-075" | child$barcode_scan_text == "FG-HH-075")] <- "2013-11-24"

# #house #38 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2018-11-06" &
                   child$settlement_barcode == "Wailea" &
                   child$extract_house_no == "38" &
                   child$child_id_pl == "54212" &
                   child$child_gender == "female" &
                   (child$barcode_scan == "FG-HH-038" | child$barcode_scan_text == "FG-HH-038")] <- "2018-11-07"

#
# ####################################################
# # Lobau #
#
# #house #49 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2015-03-05" &
                   child$settlement_barcode == "Lobau" &
                   child$extract_house_no == "49" &
                   child$child_id_pl == "53815" &
                   child$child_gender == "male" &
                   (child$barcode_scan == "FB-HH-049" | child$barcode_scan_text == "FB-HH-049")] <- "2015-03-15"

# #Feces kit was not picked up at house #21 but was picked up at the correct
# #house #20
feces$barcode_scan_text [feces$barcode_scan_text == "FB-HH-021" &
                           feces$settlement_barcode == "Lobau" &
                           feces$extract_house_no == "21" &
                           feces$KEY == "uuid:edcc7ad0-4915-41b7-81ed-eafbda8fd7b7"] <- "FB-HH-020"
feces$extract_house_no [feces$barcode_scan_text == "FB-HH-020" &
                          feces$settlement_barcode == "Lobau" &
                          feces$extract_house_no == "21" &
                          feces$KEY == "uuid:edcc7ad0-4915-41b7-81ed-eafbda8fd7b7"] <- 20


#
# ####################################################
# # Wainidinu #
#
# #house #25 barcode_bloodspot = F-P1-000002 but this is a duplicate, replace
# #with barcode_bloodspot = F-P1-000007 for 17/10/2019 - Jeff F
child$barcode_bloodspot [child$barcode_bloodspot == "F-P1-000002" &
                   child$settlement_barcode == "Wainidinu" &
                   child$extract_house_no == "25" &
                   child$today == "2019-10-17" &
                   child$child_id_pl == "54194" &
                   (child$barcode_scan == "FM-HH-025" | child$barcode_scan_text == "FM-HH-025")] <- "F-P1-000007"

#
# ####################################################
# # Nauluvatu #
#
# #house #79 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2015-08-28" &
                   child$settlement_barcode == "Nauluvatu" &
                   child$extract_house_no == "79" &
                   child$child_id_pl == "53882" &
                   child$child_gender == "male" &
                   (child$barcode_scan == "FE-HH-079" | child$barcode_scan_text == "FE-HH-079")] <- "2014-08-28"

# #house #69 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2015-05-05" &
                   child$settlement_barcode == "Nauluvatu" &
                   child$extract_house_no == "69" &
                   child$child_id_pl == "53840" &
                   child$child_gender == "female" &
                   (child$barcode_scan == "FE-HH-069" | child$barcode_scan_text == "FE-HH-069")] <- "2015-05-25"

# #house #69 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2015-05-05" &
                   child$settlement_barcode == "Nauluvatu" &
                   child$extract_house_no == "69" &
                   child$child_id_pl == "53841" &
                   child$child_gender == "female" &
                   (child$barcode_scan == "FE-HH-069" | child$barcode_scan_text == "FE-HH-069")] <- "2015-05-25"

# # house #79 did not receive a feces kit. Feces kit F-F0-000537 should only be
# #associated with house #017 in Muanivatu - Jeff Fine
child$feces_kit_barcode [child$feces_kit_barcode == "F-F0-000537" &
                           child$settlement_barcode == "Nauluvatu" &
                           child$extract_house_no == "79" &
                           child$child_id_pl == "53882" &
                           child$child_dob == "2014-08-28" & child$child_gender == "male"] <- NA

#
# ####################################################
# # Newtown #
#
# #house #120 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2016-07-09" &
                   child$settlement_barcode == "Newtown" &
                   child$extract_house_no == "120" &
                   child$child_id_pl == "53989" &
                   child$child_gender == "male" &
                   (child$barcode_scan == "FH-HH-120" | child$barcode_scan_text == "FH-HH-120")] <- "2015-08-18"

# #house #129 child had incorrect dob documented - Jeff Fine
child$child_dob [child$child_dob == "2016-05-18" &
                   child$settlement_barcode == "Newtown" &
                   child$extract_house_no == "129" &
                   child$child_id_pl == "53967" &
                   child$child_gender == "male" &
                   (child$barcode_scan == "FH-HH-129" | child$barcode_scan_text == "FH-HH-129")] <- "2015-05-18"

# #house #138 survey_status = 1 should be survey_status = 7 as family has
# #refused for child to participate in the study - Jeff Fine (31/10/2019)
child$survey_status [child$survey_status == 1 &
                       child$settlement_barcode == "Newtown" &
                       child$extract_house_no == "138" &
                       child$today == "2019-10-31"] <- 7

# #house 51 was given F-F0-000089 but F-F0-000360 was picked up.
feces.sample$barcode_feces [feces.sample$barcode_feces == "F-F0-000360" &
                              feces.sample$respondent_id == "51286"] <- "F-F0-000089"

# #house 48 was given F-F0-000360 but F-F0-000089 was picked up.
feces.sample$barcode_feces [feces.sample$barcode_feces == "F-F0-000089" &
                              feces.sample$respondent_id == "50286"] <- "F-F0-000360"

# #house 42 incorrect feces barcode manually written in.
feces.sample$barcode_feces_text [feces.sample$barcode_feces_text == "F-F0-000001" &
                              feces.sample$respondent_id == "51266"] <- "F-F0-000087"

# #house #1 child had incorrect dob documented and is >5 - Jeff Fine
child$child_dob [child$child_dob == "2015-02-12" &
                   child$settlement_barcode == "Newtown" &
                   child$extract_house_no == "1" &
                   child$child_id_pl == "53803" &
                   child$child_gender == "male" &
                   (child$barcode_scan == "FH-HH-001" | child$barcode_scan_text == "FH-HH-001")] <- "2014-02-12"
Monash-RISE/riseR documentation built on Dec. 11, 2019, 9:49 a.m.