RISE_FJ/T0_baseline/O3_T0_FJ-corrections.R

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

##################
#check data to identify fixes
##################
test <- hhd.child %>% 
  filter (is.na(name_id)) #3 - this is weird; no idea how this is happening; for now, just delete them but need to see how it could be happening ???????
#2 from Nauluvatu #7 on 25 June 2019; other from 24 June I think
hhd.child <- hhd.child %>% 
  filter (!is.na(name_id))
test <- hhd.child %>% 
  filter (is.na(name_id)) 
rm(test)


##################
##################
##################

# FIXES and their descriptions can be found here:
#  https://docs.google.com/spreadsheets/d/1GmHauYlkHSY0vog9NmL-5rKlsSnaq_nRWFlgRvzD64s/edit#gid=884184821

#24 June 2019 - found that there was an error in the gender calculate field (child_gender_final) that needs to be fixed - has been fixed in the survey
hhd.person <- hhd.person %>% 
  mutate(child_gender_final = ifelse(!is.na(child_gender_final), child_gender_final, child_gender2)) %>% 
  mutate (person_gender = ifelse (!is.na(person_gender), person_gender, child_gender_final))

#25 June 2019 - need to fix person_dob; it is being changed to NA if they didn't provide dob
#hhd.person <- hhd.person %>% 
#  mutate(test = ifelse(!is.na(age) & dob == date("29/02/2000"),  NA, person_dob))


##################
# KINOYA
##################
#Kinoya house # 1 change to 95
house$extract_house_no[house$settlement_barcode == "Kinoya" & house$duration == 1163 & house$extract_house_no == "1"] <- 95

#KINOYA house # 22 repetition house already done on the 20th form for house and household to be removed from consent.
#this is best done AFTER the merge - refer to summary.R

# Kinoya #67 - 2 surveys done; survey done on the 24th was incompleted both redone on the 26th completed

#Kinoya house #95 - need to fix house barcode and house number in the consent survey
#this will need to be fixed in consent corrections O3_T0_FJ-consent_corrections.R

##################
# NAULUVATU
##################

#Nauluvatu house #20 - need to fix household name in the house and survey
house$name_head[house$settlement_barcode == "Nauluvatu" & house$extract_house_no == 20 &
                  house$duration == 1179 & house$name_head == "Lepani Vuinakelo" ] <- "Lute Vuinakelo"
house$hhd_name[house$settlement_barcode == "Nauluvatu" & house$extract_house_no == 20 & 
                 house$duration == 1179 & house$hhd_name == "Lepani Vuinakelo" ] <- "Lute Vuinakelo"
house$hhd_id[house$settlement_barcode == "Nauluvatu" & house$extract_house_no == 20 & 
               house$duration == 1179 & house$hhd_id == "Lepani Vuinakelo" ] <- "Lute Vuinakelo"


##################
# MUANIVATU
##################

#Muanivatu house #17 need to fix household name to match hhd_id of household survey
hhd$hhd_id[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 17 &
               hhd$duration == 1468 & hhd$hhd_id == "Anitekini Sivo"] <- "Mataiasi"
hhd$hhd_name[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 17 & 
                 hhd$duration == 1468 & hhd$hhd_name == "Anitekini Sivo"] <- "Mataiasi"

hhd$name1[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 17 &
                  hhd$duration == 1468 & hhd$name1 == "Reapi Waitalea (age = 3.3)"] <- "Mataiasi (age = 38.1)"
hhd$name2[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 17 &
            hhd$duration == 1468 & hhd$name2 == "Epeli Goneca (age = 0.1)"] <- "Sereseini (age = 35)"
hhd$name3[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 17 &
            hhd$duration == 1468 & hhd$name3 == "Anitekini Sivo (age = )"] <- "Anitekini (age = 5)"

#Muanivatu house #22 need to fix household name to match hhd_id of household survey
hhd$hhd_id[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 22 &
             hhd$duration == 1387 & hhd$hhd_id == "Masilina Caginitabua" ] <- "Masilina Liganitoba"
hhd$hhd_name[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 22 & 
               hhd$duration == 1387 & hhd$hhd_name == "Masilina Caginitabua" ] <- "Masilina Liganitoba"

#Muanivatu house# 55 need to fix household name to match hhd_id of household survey
hhd$hhd_name[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 55 &
               hhd$duration == 1841 & hhd$hhd_name == "Salote Ditamani"] <- "Salote Ditamana"
hhd$name_head[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 55 & 
                hhd$duration == 1841 & hhd$name_head == "Salote Ditamani"] <- "Salote Ditamana"
hhd$hhd_id[hhd$settlement_barcode == "Muanivatu" & hhd$extract_house_no == 55 & 
             hhd$duration == 1841 & hhd$hhd_id == "Salote Ditamani"] <- "Salote Ditamana"

house$hhd_id[house$settlement_barcode == "Muanivatu" & house$extract_house_no == 55 &
               house$duration == 787 & house$hhd_id == "Salote Ditamani" ] <- "Salote Ditamana"
house$hhd_name[house$settlement_barcode == "Muanivatu" & house$extract_house_no == 55 &
                 house$duration == 787 & house$hhd_name == "Salote Ditamani" ] <- "Salote Ditamana"
house$hhd_id[house$settlement_barcode == "Muanivatu" & house$extract_house_no == 55 & 
               house$duration == 787 & is.na(house$hhd_id) ] <- "Salote Ditamana"
house$name_head[house$settlement_barcode == "Muanivatu" & house$extract_house_no == 55 & 
                  house$duration == 787 & house$name_head == "Salote Ditamani" ] <- "Salote Ditamana"
house$adult_name1[house$settlement_barcode == "Muanivatu" & house$extract_house_no == 55 & 
                    house$duration == 787 & house$adult_name1 == "Kelevi Rasari" ] <- "Salote Ditamana"


##################
# NEWTOWN
##################

#Newtown House # 86 household name to match house and consent
hhd$hhd_name[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 86 &
             hhd$duration == 1269 & hhd$hhd_name == "Epeli"] <- "Samuela Toko"
hhd$name_head[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 86 & 
            hhd$duration == 1269 & hhd$name_head == "Epeli"] <- "Samuela Toko"
hhd$hhd_id[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 86 & 
             hhd$duration == 1269 & hhd$hhd_id == "Epeli"] <- "Samuela Toko"

#Newtown House # 108 household name to match hhd and consent
hhd$hhd_name[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 108 &
               hhd$duration == 2042 & hhd$hhd_name == "Saula Naiqoqo"] <- "Kuini Naco"
hhd$name_head[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 108 & 
                hhd$duration == 2042 & hhd$name_head == "Saula Naiqoqo"] <- "Kuini Naco"
hhd$hhd_id[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 108 & 
             hhd$duration == 2042 & hhd$hhd_id == "Saula Naiqoqo"] <- "Kuini Naco"
house$hhd_id[house$settlement_barcode == "Newtown" & house$extract_house_no == 108 & 
               house$duration == 392 & house$hhd_id == "Saula Naiqoqo"] <- "Kuini Naco"

#Newtown House # 51 household name to match house and consent
house$hhd_name[house$settlement_barcode == "Newtown" & house$extract_house_no == 51 &
               house$duration == 762 & house$hhd_name == "Jean Baptist Kaufuti"] <- "Theresa Hoyte"
house$name_head[house$settlement_barcode == "Newtown" & house$extract_house_no == 51 & 
                house$duration == 762 & house$name_head == "Jean Baptist Kaufuti"] <- "Theresa Hoyte"
house$hhd_id[house$settlement_barcode == "Newtown" & house$extract_house_no == 51 & 
             house$duration == 762 & house$hhd_id == "Jean Baptist Kaufuti"] <- "Theresa Hoyte"

#Newtown House # 54 need to fix household name to Harold Chanel Koi for house survey
house$hhd_id[house$settlement_barcode == "Newtown" & house$extract_house_no == 54 &
               house$duration == 510 & house$hhd_id == "Horald Chanel Koi" ] <- "Harold Chanel Koi"
house$hhd_name[house$settlement_barcode == "Newtown" & house$extract_house_no == 54 &
               house$duration == 510 & house$hhd_name == "Horald Chanel Koi" ] <- "Harold Chanel Koi"
house$hhd_id[house$settlement_barcode == "Newtown" & house$extract_house_no == 54 & 
               house$duration == 510 & is.na(house$hhd_id) ] <- "Harold Chanel Koi"
house$name_head[house$settlement_barcode == "Newtown" & house$extract_house_no == 54 & 
                house$duration == 510 & house$name_head == "Horald Chanel Koi" ] <- "Harold Chanel Koi"
house$adult_name1[house$settlement_barcode == "Newtown" & house$extract_house_no == 54 & 
                  house$duration == 510 & house$adult_name1 == "Horald Chanel Koi" ] <- "Harold Chanel Koi"

#Newtown house #16 need to fix household name to match hhd_id of household survey
house$name_head[house$settlement_barcode == "Newtown" & house$extract_house_no == 16 &
                  house$duration == 923 & house$name_head == "Asinate"] <- "Asinate Bituleka"
house$hhd_name[house$settlement_barcode == "Newtown" & house$extract_house_no == 16 & 
                 house$duration == 923 & house$hhd_name == "Asinate"] <- "Asinate Bituleka"
house$hhd_id[house$settlement_barcode == "Newtown" & house$extract_house_no == 16 & 
               house$duration == 923 & house$hhd_id == "Asinate" ] <- "Asinate Bituleka"

#Newtown house #22 need to fix household name to match hhd_id of household survey
house$name_head[house$settlement_barcode == "Newtown" & house$extract_house_no == 22 &
                  house$duration == 189 & house$name_head == "Masilina Caginitabua"] <- "Masilina Liganitoba"
house$hhd_name[house$settlement_barcode == "Newtown" & house$extract_house_no == 22 & 
                 house$duration == 189 & house$hhd_name == "Masilina Caginitabua"] <- "Masilina Liganitoba"
house$hhd_id[house$settlement_barcode == "Newtown" & house$extract_house_no == 22 & 
               house$duration == 189 & house$hhd_id == "Masilina Caginitabua" ] <- "Masilina Liganitoba"
house$adult_name1[house$settlement_barcode == "Newtown" & house$extract_house_no == 22 & 
                    house$duration == 189 & house$adult_name1 == "Masilina Caginitabua" ] <- "Masilina Liganitoba"

# House # 62 Newtown change hhd so house consent and household is able to merge
hhd$hhd_name[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 62 &
               hhd$duration == 2863 & hhd$hhd_name == "Jope jilimaitoga" ] <- "Jope Jilimaitoga"
hhd$hhd_id[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 62 & 
             hhd$duration == 2863 & hhd$hhd_id == "Jope jilimaitoga" ] <- "Jope Jilimaitoga"
hhd$name_head[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 62 & 
                hhd$duration == 2863 & hhd$name_head == "Jope jilimaitoga" ] <- "Jope Jilimaitoga"

#House # 133 Newtown change hhd so consent house and household is able to merge
house$hhd_id[house$settlement_barcode == "Newtown" & house$extract_house_no == 133 &
               house$duration == 672 & house$hhd_id == "Seru Bakaniceva" ] <- "Naomi Dimate Vueti"
house$hhd_name[house$settlement_barcode == "Newtown" & house$extract_house_no == 133 &
                 house$duration == 672 & house$hhd_name == "Seru Bakaniceva" ] <- "Naomi Dimate Vueti"
house$adult_name1[house$settlement_barcode == "Newtown" & house$extract_house_no == 133 & 
                    house$duration == 672 & house$adult_name1 == "Seru Bakaniceva" ] <- "Naomi Dimate Vueti"

#fix head of household name in hhd survey for House # 133
hhd$hhd_id[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 133 & 
             hhd$duration == 2892 & hhd$hhd_id == "Seru Bakaniceva"] <- "Naomi Dimate Vueti"
hhd$name_head[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 133 & 
                hhd$duration == 2892 & hhd$name_head == "Seru Bakaniceva"] <- "Naomi Dimate Vueti"
hhd$hhd_name[hhd$settlement_barcode == "Newtown" & hhd$extract_house_no == 133 &
               hhd$duration == 2892 & hhd$hhd_name == "Seru Bakaniceva" ] <- "Naomi Dimate Vueti"

##################
# MUANIKOSO
##################

#Muanikoso House # 13 need to fix household name to Manjula Devi for house survey
house$hhd_id[house$settlement_barcode == "Muanikoso" & house$extract_house_no == 13 &
               house$duration == 1192 & house$hhd_id == "Manjula devi" ] <- "Manjula Devi"
house$hhd_name[house$settlement_barcode == "Muanikoso" & house$extract_house_no == 13 &
                 house$duration == 1192 & house$hhd_name == "Manjula devi" ] <- "Manjula Devi"
house$adult_name1[house$settlement_barcode == "Muanikoso" & house$extract_house_no == 13 & 
               house$duration == 1192 & house$adult_name1 == "Manjula devi" ] <- "Manjula Devi"

#fix hhd name to Majula Devi so that its able to merge with consent and house survey
hhd$hhd_id[hhd$settlement_barcode == "Muanikoso" & hhd$extract_house_no == 13 & 
             hhd$duration == 2873 & hhd$hhd_id == "Manjula devi"] <- "Manjula Devi"
hhd$name_head[hhd$settlement_barcode == "Muanikoso" & hhd$extract_house_no == 13 & 
                hhd$duration == 2873 & hhd$name_head == "Manjula devi"] <- "Manjula Devi"

#House # 12 Muanikoso hhd name for house and household to be changed so survey is able to merge with consent
house$hhd_id[house$settlement_barcode == "Muanikoso" & house$extract_house_no == 12 &
               house$duration == 1263 & house$hhd_id == "Senikarewa Bale" ] <- "Tavenisa Lewa"
hhd$hhd_name[hhd$settlement_barcode == "Muanikoso" & hhd$extract_house_no == 12 &
                 hhd$duration == 2497 & hhd$hhd_name == "Senikarewa Bale" ] <- "Tavenisa Lewa"
hhd$hhd_id[hhd$settlement_barcode == "Muanikoso" & hhd$extract_house_no == 12 & 
             hhd$duration == 2497 & hhd$hhd_id == "Senikarewa Bale" ] <- "Tavenisa Lewa"
hhd$name_head[hhd$settlement_barcode == "Muanikoso" & hhd$extract_house_no == 12 & 
                hhd$duration == 2497 & hhd$name_head == "Senikarewa Bale" ] <- "Tavenisa Lewa"

##################
# KOMAVE
##################

#House # 9 Komave change hhd name to be able to merge with house and household.
house$hhd_id[house$settlement_barcode == "Komave" & house$extract_house_no == 9 &
               house$duration == 398 & house$hhd_id == "Anuradha Chand"] <- "Kevin Nilesh Chand"
house$name_head[house$settlement_barcode == "Komave" & house$extract_house_no == 9 & 
                house$duration == 398 & house$name_head == "Anuradha Chand"] <- "Kevin Nilesh Chand"
house$hhd_name[house$settlement_barcode == "Komave" & house$extract_house_no == 9 &
               house$duration == 398 & house$hhd_name == "Anuradha Chand"] <- "Kevin Nilesh Chand"

#House # 44 Komave change hhd name to be able to merge with house and household.
house$hhd_id[house$settlement_barcode == "Komave" & house$extract_house_no == 44 &
               house$duration == 955 & house$hhd_id == "Mohini Lata" ] <- "Rohini Lata"
house$name_head[house$settlement_barcode == "Komave" & house$extract_house_no == 44 &
               house$duration == 955 & house$name_head == "Mohini Lata" ] <- "Rohini Lata"
house$hhd_name[house$settlement_barcode == "Komave" & house$extract_house_no == 44 &
                  house$duration == 955 & house$hhd_name == "Mohini Lata" ] <- "Rohini Lata"

hhd$hhd_name[hhd$settlement_barcode == "Komave" & hhd$extract_house_no == 5 &
               hhd$duration == 1446 & hhd$hhd_name == "Hazin Begum" ] <- "Hazina Begum"
hhd$hhd_id[hhd$settlement_barcode == "Komave" & hhd$extract_house_no == 5 & 
             hhd$duration == 1446 & hhd$hhd_id == "Hazin Begum" ] <- "Hazina Begum"
hhd$name_head[hhd$settlement_barcode == "Komave" & hhd$extract_house_no == 5 & 
                hhd$duration == 1446 & hhd$name_head == "Hazin Begum" ] <- "Hazina Begum"

##################
# WAINIDINU
##################

# House # 14 Wainidinu change hhd so house cosent and household is able to merge
hhd$hhd_name[hhd$settlement_barcode == "Wainidinu" & hhd$extract_house_no == 14 &
               hhd$duration == 1940 & hhd$hhd_name == "Stino Ratu" ] <- "Epeli Rakai"
hhd$hhd_id[hhd$settlement_barcode == "Wainidinu" & hhd$extract_house_no == 14 & 
             hhd$duration == 1940 & hhd$hhd_id == "Stino Ratu" ] <- "Epeli Rakai"
hhd$name_head[hhd$settlement_barcode == "Wainidinu" & hhd$extract_house_no == 14 & 
                hhd$duration == 1940 & hhd$name_head == "Stino Ratu" ] <- "Epeli Rakai"

##################
# WAINIVOKAI
##################

#House # 36 Wainivokai change hhd name to be able to merge with house and household.
house$hhd_id[house$settlement_barcode == "Wainivokai" & house$hhd_id == "Menani Qoli" ] <- "Maoni Mala Kalou"

##################
# LOBAU
##################

#House #52 Lobau change hhd name to be able to merge with house and household.
house$hhd_id[house$settlement_barcode == "Lobau" & house$extract_house_no == 52 &
               house$duration == 437 & house$hhd_id == "Jitesh Kamal Prasad" ] <- "Jiten Kamal Prasad"
house$name_head[house$settlement_barcode == "Lobau" & house$extract_house_no == 52 &
                  house$duration == 437 & house$name_head == "Jitesh Kamal Prasad" ] <- "Jiten Kamal Prasad"
house$hhd_name[house$settlement_barcode == "Lobau" & house$extract_house_no == 52 &
                 house$duration == 437 & house$hhd_name == "Jitesh Kamal Prasad" ] <- "Jiten Kamal Prasad"

#House #110 Lobau change hhd name to be able to merge with house and household.
house$hhd_id[house$settlement_barcode == "Lobau" & house$extract_house_no == 110 &
               house$duration == 536 & house$hhd_id == "Maria Maivalenisau" ] <- "Pisalieli Seleivalu"
house$name_head[house$settlement_barcode == "Lobau" & house$extract_house_no == 110 &
                  house$duration == 536 & house$name_head == "Maria Maivalenisau" ] <- "Pisalieli Seleivalu"
house$hhd_name[house$settlement_barcode == "Lobau" & house$extract_house_no == 110 &
                 house$duration == 536 & house$hhd_name == "Maria Maivalenisau" ] <- "Pisalieli Seleivalu"

#House #107 Lobau change hhd name to be able to merge with house and household.
house$hhd_id[house$settlement_barcode == "Lobau" & house$extract_house_no == 107 &
               house$duration == 645 & house$hhd_id == "Sherina nazreen husein" ] <- "Arfat"
house$name_head[house$settlement_barcode == "Lobau" & house$extract_house_no == 107 &
                  house$duration == 645 & house$name_head == "Sherina nazreen husein" ] <- "Arfat"
house$hhd_name[house$settlement_barcode == "Lobau" & house$extract_house_no == 107 &
                 house$duration == 645 & house$hhd_name == "Sherina nazreen husein" ] <- "Arfat"
Monash-RISE/riseR documentation built on Dec. 11, 2019, 9:49 a.m.