rm(list=ls(all=t))
filename <- "Section_8" # !!!Update filename
functions_vers <- "functions_1.8.R" # !!!Update helper functions file
source (functions_vers)
Visually inspect variables in "dictionary.csv" and flag for risk, using the following flags:
# Direct PII: Respondent Names, Addresses, Identification Numbers, Phone Numbers
# Direct PII-team: Interviewer Names, other field team names
# Indirect PII-ordinal: Date of birth, Age, income, education, household composition.
# Indirect PII-categorical: Gender, education, ethnicity, nationality,
# occupation, employer, head of household, marital status
# GPS: Longitude, Latitude
# Small Location: Location (<100,000)
# Large Location (>100,000)
# Weight: weightVar
# Household ID: hhId,
# Open-ends: Review responses for any sensitive information, redact as necessary
mydata$household_id <- zap_labels(mydata$household_id)
# !!!No Direct PII - team
# !!!No Small locations
# Top code high income/expense to the 99.5 percentile
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q7__1)[na.exclude(mydata$m_s8q7__1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q7__1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q7__1. sHq12: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## -998 50 100 150 200 300 350 400 500 600 700 1000 1400 1500 2000 3000 3500 5000 5800 6350 6500 7000 7305 7500
## 1 1 1 1 3 1 1 2 7 1 2 13 1 7 9 11 1 15 1 1 1 5 1 1
## 7800 8000 9000 10000 12000 13000 15000 16000 18000 20000 30000 50000 60000 105000 <NA>
## 1 1 2 17 1 1 3 1 1 4 1 3 1 1 2159
## [1] "Frequency table after encoding"
## m_s8q7__1. sHq12: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## -998 50 100 150 200 300 350 400 500 600 700 1000
## 1 1 1 1 3 1 1 2 7 1 2 13
## 1400 1500 2000 3000 3500 5000 5800 6350 6500 7000 7305 7500
## 1 7 9 11 1 15 1 1 1 5 1 1
## 7800 8000 9000 10000 12000 13000 15000 16000 18000 20000 30000 50000
## 1 1 2 17 1 1 3 1 1 4 1 3
## 60000 76875 or more <NA>
## 1 1 2159
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q8__1)[na.exclude(mydata$m_s8q8__1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q8__1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q8__1. sHq13: What was the value of the in-kind goods? Magkano po ang halaga ng hindi
## -998 200 300 500 600 1000 1570 1983 2300 2635 2695 3000 5000 5782 6000 6400 6900 7000 7100 7420 7500 8000 8330 8350 8723 9000 9500 9800
## 2 1 1 1 1 2 1 1 1 1 1 1 2 1 2 1 1 2 2 1 1 7 1 1 1 5 2 2
## 9900 9952 9953 10000 20000 <NA>
## 1 3 1 94 1 2139
## [1] "Frequency table after encoding"
## m_s8q8__1. sHq13: What was the value of the in-kind goods? Magkano po ang halaga ng hindi
## -998 200 300 500 600 1000 1570 1983 2300 2635 2695 3000
## 2 1 1 1 1 2 1 1 1 1 1 1
## 5000 5782 6000 6400 6900 7000 7100 7420 7500 8000 8330 8350
## 2 1 2 1 1 2 2 1 1 7 1 1
## 8723 9000 9500 9800 9900 9952 9953 10000 12750 or more <NA>
## 1 5 2 2 1 3 1 94 1 2139
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q7__2)[na.exclude(mydata$m_s8q7__2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q7__2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q7__2. sHq12: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## 300 400 500 600 1000 1800 2500 5000 7000 10000 <NA>
## 1 1 3 1 2 1 1 4 1 1 2269
## [1] "Frequency table after encoding"
## m_s8q7__2. sHq12: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## 300 400 500 600 1000 1800 2500 5000 7000 9775 or more <NA>
## 1 1 3 1 2 1 1 4 1 1 2269
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q8__2)[na.exclude(mydata$m_s8q8__2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q8__2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q8__2. sHq13: What was the value of the in-kind goods? Magkano po ang halaga ng hindi
## 7700 10000 <NA>
## 1 1 2283
## [1] "Frequency table after encoding"
## m_s8q8__2. sHq13: What was the value of the in-kind goods? Magkano po ang halaga ng hindi
## 7700 9988 or more <NA>
## 1 1 2283
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q7__3)[na.exclude(mydata$m_s8q7__3)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q7__3", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q7__3. sHq12: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## 500 550 2000 4000 <NA>
## 1 1 1 1 2281
## [1] "Frequency table after encoding"
## m_s8q7__3. sHq12: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## 500 550 2000 3970 or more <NA>
## 1 1 1 1 2281
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q8__3)[na.exclude(mydata$m_s8q8__3)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q8__3", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q8__3. sHq13: What was the value of the in-kind goods? Magkano po ang halaga ng hindi
## 12000 <NA>
## 1 2284
## [1] "Frequency table after encoding"
## m_s8q8__3. sHq13: What was the value of the in-kind goods? Magkano po ang halaga ng hindi
## 12000 or more <NA>
## 1 2284
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q16__1)[na.exclude(mydata$m_s8q16__1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q16__1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q16__1. sHq24: How much cash from outside resources was used to expand this enterprise?
## 0 85 150 200 500 800 1000 1200 1500 2000 2300 3000 3500 3750 4000 4500 5000 6000 6500 7000 8000 10000 15000 17000 20000 30000 40000 50000
## 2 1 2 3 7 1 8 2 2 6 1 8 1 1 2 1 19 5 2 8 1 19 3 1 3 4 1 4
## 65000 <NA>
## 1 2166
## [1] "Frequency table after encoding"
## m_s8q16__1. sHq24: How much cash from outside resources was used to expand this enterprise?
## 0 85 150 200 500 800 1000 1200 1500 2000 2300 3000
## 2 1 2 3 7 1 8 2 2 6 1 8
## 3500 3750 4000 4500 5000 6000 6500 7000 8000 10000 15000 17000
## 1 1 2 1 19 5 2 8 1 19 3 1
## 20000 30000 40000 50000 56149 or more <NA>
## 3 4 1 4 1 2166
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q17__1)[na.exclude(mydata$m_s8q17__1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q17__1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q17__1. sHq25: What was the value of the in-kind resources from outside sources used to
## 2000 3000 3800 4000 7700 9000 10000 20000 30000 <NA>
## 1 2 1 1 1 2 11 1 1 2264
## [1] "Frequency table after encoding"
## m_s8q17__1. sHq25: What was the value of the in-kind resources from outside sources used to
## 2000 3000 3800 4000 7700 9000 10000 20000 28999 or more <NA>
## 1 2 1 1 1 2 11 1 1 2264
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q27__1)[na.exclude(mydata$m_s8q27__1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q27__1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q27__1. sHq38: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## -998 50 200 250 300 500 600 800 1000 1500 2000 2500 2800 3000 4000 4500 5000 6000 7000 7305 8000 10000 12000 15000 30000 35000 60000 <NA>
## 1 1 5 1 2 11 1 1 15 3 11 1 1 12 2 1 21 3 6 1 1 5 2 3 1 1 1 2171
## [1] "Frequency table after encoding"
## m_s8q27__1. sHq38: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## -998 50 200 250 300 500 600 800 1000 1500 2000 2500
## 1 1 5 1 2 11 1 1 15 3 11 1
## 2800 3000 4000 4500 5000 6000 7000 7305 8000 10000 12000 15000
## 1 12 2 1 21 3 6 1 1 5 2 3
## 30000 35000 45875 or more <NA>
## 1 1 1 2171
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q28__1)[na.exclude(mydata$m_s8q28__1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q28__1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q28__1. sHq39: What was the value of the in-kind goods? Magkano po ang halaga ng gamit
## -998 300 500 600 750 2000 2695 3000 5000 5782 7900 8000 8050 8330 9000 10000 <NA>
## 2 1 1 1 1 1 1 1 3 1 1 3 1 1 1 23 2242
## [1] "Frequency table after encoding"
## m_s8q28__1. sHq39: What was the value of the in-kind goods? Magkano po ang halaga ng gamit
## -998 300 500 600 750 2000 2695 3000 5000 5782 7900 8000
## 2 1 1 1 1 1 1 1 3 1 1 3
## 8050 8330 9000 10000 or more <NA>
## 1 1 1 23 2242
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q27__2)[na.exclude(mydata$m_s8q27__2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q27__2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q27__2. sHq38: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## 4000 5000 <NA>
## 1 1 2283
## [1] "Frequency table after encoding"
## m_s8q27__2. sHq38: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## 4000 4995 or more <NA>
## 1 1 2283
percentile_99.5 <- floor(quantile(na.exclude(mydata$m_s8q27__3)[na.exclude(mydata$m_s8q27__3)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="m_s8q27__3", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## m_s8q27__3. sHq38: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## 2000 <NA>
## 1 2284
## [1] "Frequency table after encoding"
## m_s8q27__3. sHq38: How much did you spend in cash? Magkano po ang perang nagastos ninyo?
## 2000 or more <NA>
## 1 2284
# !!!Include relevant variables in list below (Indirect PII - Categorical, and Ordinal if not processed yet)
indirect_PII <- c("m_s8q3__1",
"m_s8q3__2",
"m_s8q3__3",
"m_s8q12__1",
"m_s8q12__2",
"m_s8q21__1",
"m_s8q21__2",
"m_s8q21__3")
capture_tables (indirect_PII)
# Recode those with very specific values.
break_ocup <- c(-999,-998,-888, 8, 15, 21, 24, 27, 29, 30, 34, 37, 43)
labels_ocup <- c("Refused to answer"=1,
"Don't know"=2,
"Other: Specify "=3,
"Other"=4,
"Other"=5,
"Food processing, wood working, garment and other craft and related trades workers"=6,
"Other"=7,
"Other"=8,
"Other"=9,
"Other"=10,
"Street and related sales and service workers"=11,
"Other"=12,
"Other"=13)
mydata <- ordinal_recode (variable="m_s8q3__1", break_points=break_ocup, missing=999999, value_labels=labels_ocup)
## [1] "Frequency table before encoding"
## m_s8q3__1. sHq6: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Other: Specify Scavenging In Dumpsites
## 10 2
## Vulcanizing (rubber workers) Consumer store operator
## 1 92
## Charcoal Makers And Related Workers Food Processing and Related Trades Workers
## 1 16
## General Managers/Managing-Proprietors Handicraft Workers In Wood, Textile, Leather, Chemicals And Related Workers
## 1 2
## Market Stall Vendors, Street Vendors And Related Workers Motor Vehicle Drivers
## 157 2
## Textile, Garment And Related Trades Workers <NA>
## 1 2000
## recoded
## [-999,-998) [-998,-888) [-888,8) [8,15) [15,21) [21,24) [24,27) [27,29) [29,30) [30,34) [34,37) [37,43) [43,1e+06)
## -888 0 0 10 0 0 0 0 0 0 0 0 0 0
## 8 0 0 0 2 0 0 0 0 0 0 0 0 0
## 15 0 0 0 0 1 0 0 0 0 0 0 0 0
## 21 0 0 0 0 0 92 0 0 0 0 0 0 0
## 24 0 0 0 0 0 0 1 0 0 0 0 0 0
## 27 0 0 0 0 0 0 0 16 0 0 0 0 0
## 29 0 0 0 0 0 0 0 0 1 0 0 0 0
## 30 0 0 0 0 0 0 0 0 0 2 0 0 0
## 34 0 0 0 0 0 0 0 0 0 0 157 0 0
## 37 0 0 0 0 0 0 0 0 0 0 0 2 0
## 43 0 0 0 0 0 0 0 0 0 0 0 0 1
## [1] "Frequency table after encoding"
## m_s8q3__1. sHq6: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Other: Specify Other
## 10 26
## Food processing, wood working, garment and other craft and related trades workers Street and related sales and service workers
## 92 157
## <NA>
## 2000
## [1] "Inspect value labels and relabel as necessary"
## Refused to answer Don't know
## 1 2
## Other: Specify Other
## 3 4
## Other Food processing, wood working, garment and other craft and related trades workers
## 5 6
## Other Other
## 7 8
## Other Other
## 9 10
## Street and related sales and service workers Other
## 11 12
## Other
## 13
break_ocup <- c(-999,-998, -888, 21, 29, 30, 34)
labels_ocup <- c("Refused to answer"=1,
"Don't know"=2,
"Other: Specify"=3,
"Other"=4,
"Other"=5,
"Other"=6,
"Other"=7)
mydata <- ordinal_recode (variable="m_s8q3__2", break_points=break_ocup, missing=999999, value_labels=labels_ocup)
## [1] "Frequency table before encoding"
## m_s8q3__2. sHq6: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Refused to answer Other: Specify
## 1 4
## Consumer store operator General Managers/Managing-Proprietors
## 4 1
## Handicraft Workers In Wood, Textile, Leather, Chemicals And Related Workers Market Stall Vendors, Street Vendors And Related Workers
## 1 14
## <NA>
## 2260
## recoded
## [-999,-998) [-998,-888) [-888,21) [21,29) [29,30) [30,34) [34,1e+06)
## -999 1 0 0 0 0 0 0
## -888 0 0 4 0 0 0 0
## 21 0 0 0 4 0 0 0
## 29 0 0 0 0 1 0 0
## 30 0 0 0 0 0 1 0
## 34 0 0 0 0 0 0 14
## [1] "Frequency table after encoding"
## m_s8q3__2. sHq6: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Refused to answer Other: Specify Other <NA>
## 1 4 20 2260
## [1] "Inspect value labels and relabel as necessary"
## Refused to answer Don't know Other: Specify Other Other Other Other
## 1 2 3 4 5 6 7
break_ocup <- c(-999,-998,-888,1)
labels_ocup <- c("Refused to answer"=1,
"Don't know"=2,
"Other: Specify"=3,
"Other"=4)
mydata <- ordinal_recode (variable="m_s8q3__3", break_points=break_ocup, missing=999999, value_labels=labels_ocup)
## [1] "Frequency table before encoding"
## m_s8q3__3. sHq6: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Hairdresser/Barber/Beautician Market Stall Vendors, Street Vendors And Related Workers
## 1 3
## <NA>
## 2281
## recoded
## [-999,-998) [-998,-888) [-888,1) [1,1e+06)
## 20 0 0 0 1
## 34 0 0 0 3
## [1] "Frequency table after encoding"
## m_s8q3__3. sHq6: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Other <NA>
## 4 2281
## [1] "Inspect value labels and relabel as necessary"
## Refused to answer Don't know Other: Specify Other
## 1 2 3 4
break_ocup <- c(-999,-998,-888, 1,4,14,20,21,22,27,30,34,37,43,44)
labels_ocup <- c("Refused to answer"=1,
"Don't know"=2,
"Other: Specify"=3,
"Other"=4,
"Other"=5,
"Other"=6,
"Other"=7,
"Other"=8,
"Other"=9,
"Other"=10,
"Other"=11,
"Street and related sales and service workers"=12,
"Other"=13,
"Other"=14,
"Other"=15,
"Other"=16)
mydata <- ordinal_recode (variable="m_s8q12__1", break_points=break_ocup, missing=999999, value_labels=labels_ocup)
## [1] "Frequency table before encoding"
## m_s8q12__1. sHq18: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Other: Specify Inland And Coastal Waters Fishermen
## 11 10
## Manufacturing Pyrotechnics Extraction of lard/oil
## 2 2
## Hairdresser/Barber/Beautician Consumer store operator
## 2 19
## Blacksmiths, Tool-Makers And Related Trades Workers Food Processing and Related Trades Workers
## 2 13
## Handicraft Workers In Wood, Textile, Leather, Chemicals And Related Workers Market Stall Vendors, Street Vendors And Related Workers
## 6 86
## Motor Vehicle Drivers Textile, Garment And Related Trades Workers
## 2 3
## Wood Treaters, Cabinet Makers And Related Trades Workers 50
## 2 14
## <NA>
## 2111
## recoded
## [-999,-998) [-998,-888) [-888,1) [1,4) [4,14) [14,20) [20,21) [21,22) [22,27) [27,30) [30,34) [34,37) [37,43) [43,44) [44,1e+06)
## -888 0 0 11 0 0 0 0 0 0 0 0 0 0 0 0
## 1 0 0 0 10 0 0 0 0 0 0 0 0 0 0 0
## 4 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0
## 14 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0
## 20 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0
## 21 0 0 0 0 0 0 0 19 0 0 0 0 0 0 0
## 22 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0
## 27 0 0 0 0 0 0 0 0 0 13 0 0 0 0 0
## 30 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0
## 34 0 0 0 0 0 0 0 0 0 0 0 86 0 0 0
## 37 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0
## 43 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0
## 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2
## 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14
## [1] "Frequency table after encoding"
## m_s8q12__1. sHq18: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Other: Specify Other Street and related sales and service workers
## 11 77 86
## <NA>
## 2111
## [1] "Inspect value labels and relabel as necessary"
## Refused to answer Don't know Other: Specify
## 1 2 3
## Other Other Other
## 4 5 6
## Other Other Other
## 7 8 9
## Other Other Street and related sales and service workers
## 10 11 12
## Other Other Other
## 13 14 15
## Other
## 16
break_ocup <- c(-999,-998,-888, 1)
labels_ocup <- c("Refused to answer"=1,
"Don't know"=2,
"Other: Specify"=3,
"Other"=4)
mydata <- ordinal_recode (variable="m_s8q12__2", break_points=break_ocup, missing=999999, value_labels=labels_ocup)
## [1] "Frequency table before encoding"
## m_s8q12__2. sHq18: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Other: Specify Market Stall Vendors, Street Vendors And Related Workers
## 2 2
## Motor Vehicle Drivers <NA>
## 1 2280
## recoded
## [-999,-998) [-998,-888) [-888,1) [1,1e+06)
## -888 0 0 2 0
## 34 0 0 0 2
## 37 0 0 0 1
## [1] "Frequency table after encoding"
## m_s8q12__2. sHq18: What is the nature of this enterprise ? Ano ang uri ng negosyong ito?
## Other: Specify Other <NA>
## 2 3 2280
## [1] "Inspect value labels and relabel as necessary"
## Refused to answer Don't know Other: Specify Other
## 1 2 3 4
break_ocup <- c(-999,-998,-888, 1,7,16,20,21,24,27,29,30,34,37)
labels_ocup <- c("Refused to answer"=1,
"Don't know"=2,
"Other: Specify"=3,
"Other"=4,
"Other"=5,
"Other"=6,
"Other"=7,
"Other"=8,
"Other"=9,
"Other"=10,
"Other"=11,
"Other"=12,
"Street and related sales and service workers"=13,
"Other"=14)
mydata <- ordinal_recode (variable="m_s8q21__1", break_points=break_ocup, missing=999999, value_labels=labels_ocup)
## [1] "Frequency table before encoding"
## m_s8q21__1. sHq30: What was the nature of this enterprise? Ano ang uri ng negosyong ito?
## Other: Specify Inland And Coastal Waters Fishermen
## 2 1
## Street Work Including Scavenging And Begging Grain mill workers
## 2 1
## Hairdresser/Barber/Beautician Consumer store operator
## 1 25
## Charcoal Makers And Related Workers Food Processing and Related Trades Workers
## 1 29
## General Managers/Managing-Proprietors Handicraft Workers In Wood, Textile, Leather, Chemicals And Related Workers
## 1 1
## Market Stall Vendors, Street Vendors And Related Workers Motor Vehicle Drivers
## 94 1
## <NA>
## 2126
## recoded
## [-999,-998) [-998,-888) [-888,1) [1,7) [7,16) [16,20) [20,21) [21,24) [24,27) [27,29) [29,30) [30,34) [34,37) [37,1e+06)
## -888 0 0 2 0 0 0 0 0 0 0 0 0 0 0
## 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0
## 7 0 0 0 0 2 0 0 0 0 0 0 0 0 0
## 16 0 0 0 0 0 1 0 0 0 0 0 0 0 0
## 20 0 0 0 0 0 0 1 0 0 0 0 0 0 0
## 21 0 0 0 0 0 0 0 25 0 0 0 0 0 0
## 24 0 0 0 0 0 0 0 0 1 0 0 0 0 0
## 27 0 0 0 0 0 0 0 0 0 29 0 0 0 0
## 29 0 0 0 0 0 0 0 0 0 0 1 0 0 0
## 30 0 0 0 0 0 0 0 0 0 0 0 1 0 0
## 34 0 0 0 0 0 0 0 0 0 0 0 0 94 0
## 37 0 0 0 0 0 0 0 0 0 0 0 0 0 1
## [1] "Frequency table after encoding"
## m_s8q21__1. sHq30: What was the nature of this enterprise? Ano ang uri ng negosyong ito?
## Other: Specify Other Street and related sales and service workers
## 2 63 94
## <NA>
## 2126
## [1] "Inspect value labels and relabel as necessary"
## Refused to answer Don't know Other: Specify
## 1 2 3
## Other Other Other
## 4 5 6
## Other Other Other
## 7 8 9
## Other Other Other
## 10 11 12
## Street and related sales and service workers Other
## 13 14
break_ocup <- c(-999,-998,-888,27,34)
labels_ocup <- c("Refused to answer"=1,
"Don't know"=2,
"Other: Specify"=3,
"Other"=4,
"Other"=5)
mydata <- ordinal_recode (variable="m_s8q21__2", break_points=break_ocup, missing=999999, value_labels=labels_ocup)
## [1] "Frequency table before encoding"
## m_s8q21__2. sHq30: What was the nature of this enterprise? Ano ang uri ng negosyong ito?
## Food Processing and Related Trades Workers Market Stall Vendors, Street Vendors And Related Workers
## 1 3
## <NA>
## 2281
## recoded
## [-999,-998) [-998,-888) [-888,27) [27,34) [34,1e+06)
## 27 0 0 0 1 0
## 34 0 0 0 0 3
## [1] "Frequency table after encoding"
## m_s8q21__2. sHq30: What was the nature of this enterprise? Ano ang uri ng negosyong ito?
## Other <NA>
## 4 2281
## [1] "Inspect value labels and relabel as necessary"
## Refused to answer Don't know Other: Specify Other Other
## 1 2 3 4 5
break_ocup <- c(34)
labels_ocup <- c("Other"=1)
mydata <- ordinal_recode (variable="m_s8q21__3", break_points=break_ocup, missing=999999, value_labels=labels_ocup)
## [1] "Frequency table before encoding"
## m_s8q21__3. sHq30: What was the nature of this enterprise? Ano ang uri ng negosyong ito?
## Market Stall Vendors, Street Vendors And Related Workers <NA>
## 1 2284
## recoded
## [34,1e+06)
## 34 1
## [1] "Frequency table after encoding"
## m_s8q21__3. sHq30: What was the nature of this enterprise? Ano ang uri ng negosyong ito?
## Other <NA>
## 1 2284
## [1] "Inspect value labels and relabel as necessary"
## Other
## 1
# !!!Insufficient demographic data
# !!! Identify open-end variables here:
open_ends <- c("m_s8_new_name__1",
"m_s8q3_other__1",
"m_s8q5_other__1",
"m_s8_new_name__2",
"m_s8q3_other__2",
"m_s8q5_other__2",
"m_s8_new_name__3",
"m_s8q3_other__3",
"m_s8q5_other__3",
"m_s8_expand_name__1",
"m_s8q12_other__1",
"m_s8q14_other__1",
"m_s8_expand_name__2",
"m_s8q12_other__2",
"m_s8q14_other__2",
"m_s8_close_name__1",
"m_s8q21_other__1",
"m_s8q25_other__1",
"m_endnote8__1",
"m_s8_close_name__2",
"m_s8q21_other__2",
"m_s8q25_other__2",
"m_endnote8__2",
"m_s8_close_name__3",
"m_s8q21_other__3",
"m_s8q25_other__3",
"m_endnote8__3")
report_open (list_open_ends = open_ends)
# Review "verbatims.csv". Identify variables to be deleted or redacted and their row number
mydata$m_s8q3_other__1[4] <- "Sales workers"
mydata$m_s8q3_other__1[15] <- "Sales workers"
mydata$m_s8q3_other__1[38] <- "Sales workers"
mydata$m_s8q3_other__1[51] <- "Sales workers"
mydata$m_s8q3_other__1[55] <- "Sales workers"
mydata$m_s8q3_other__1[79] <- "Sales workers"
mydata$m_s8q3_other__1[114] <- "Plant and machine operators, and assemblers"
mydata$m_s8q3_other__1[146] <- "Sales workers"
mydata$m_s8q3_other__1[166] <- "Sales workers"
mydata$m_s8q3_other__1[195] <- "Sales workers"
mydata$m_s8q3_other__1[300] <- "[language]"
mydata$m_s8q3_other__1[766] <- "Food processing, wood working, garment and other craft and related trades workers"
mydata$m_s8q3_other__1[785] <- "Food processing, wood working, garment and other craft and related trades workers"
mydata$m_s8q3_other__1[882] <- "Sales workers"
mydata$m_s8q3_other__1[935] <- "Sales workers"
mydata$m_s8q3_other__1[1020] <- "Sales workers"
mydata$m_s8q3_other__1[1088] <- "Sales workers"
mydata$m_s8q3_other__1[1095] <- "Sales workers"
mydata$m_s8q3_other__1[1143] <- "Sales workers"
mydata$m_s8q3_other__1[1174] <- "Sales workers"
mydata$m_s8q3_other__1[1184] <- "Sales workers"
mydata$m_s8q3_other__1[1214] <- "Sales workers"
mydata$m_s8q3_other__1[1220] <- "Sales workers"
mydata$m_s8q3_other__1[1223] <- "Sales workers"
mydata$m_s8q3_other__1[1225] <- "Plant and machine operators, and assemblers"
mydata$m_s8q3_other__1[1256] <- "Sales workers"
mydata$m_s8q3_other__1[1393] <- "Sales workers"
mydata$m_s8q3_other__1[1397] <- "Sales workers"
mydata$m_s8q3_other__1[1433] <- "Sales workers"
mydata$m_s8q3_other__1[1469] <- "Sales workers"
mydata$m_s8q3_other__1[1507] <- "Sales workers"
mydata$m_s8q3_other__1[1594] <- "Sales workers"
mydata$m_s8q3_other__1[1714] <- "Sales workers"
mydata$m_s8q3_other__1[1792] <- "Sales workers"
mydata$m_s8q3_other__1[1793] <- "Sales workers"
mydata$m_s8q3_other__1[1829] <- "[language]"
mydata$m_s8q3_other__1[1853] <- "Sales workers"
mydata$m_s8q3_other__1[1997] <- "Food processing, wood working, garment and other craft and related trades workers"
mydata$m_s8q3_other__1[2000] <- "Sales workers"
mydata$m_s8q3_other__1[2239] <- "Food processing, wood working, garment and other craft and related trades workers"
mydata$m_s8q3_other__1[2282] <- "Food processing, wood working, garment and other craft and related trades workers"
mydata$m_s8q3_other__2[134] <- "Sales workers"
mydata$m_s8q3_other__2[1095] <- "Sales workers"
mydata$m_s8q3_other__2[1141] <- "Sales workers"
mydata$m_s8q3_other__2[1220] <- "Sales workers"
mydata$m_s8q3_other__2[1221] <- "Sales workers"
mydata$m_s8q3_other__2[1973] <- "Sales workers"
mydata$m_s8q3_other__2[1997] <- "Sales workers"
mydata$m_s8q12_other__1[90] <- "Sales workers"
mydata$m_s8q12_other__1[445] <- "Legal, social and cultural professionals"
mydata$m_s8q12_other__1[542] <- "Sales workers"
mydata$m_s8q12_other__1[739] <- "Handicraft and printing workers"
mydata$m_s8q12_other__1[771] <- "Sales workers"
mydata$m_s8q12_other__1[819] <- "[language]"
mydata$m_s8q12_other__1[820] <- "Sales workers"
mydata$m_s8q12_other__1[835] <- "Handicraft and printing workers"
mydata$m_s8q12_other__1[1006] <- "Sales workers"
mydata$m_s8q12_other__1[1128] <- "Sales workers"
mydata$m_s8q12_other__1[1132] <- "Sales workers"
mydata$m_s8q12_other__1[1134] <- "Sales workers"
mydata$m_s8q12_other__1[1151] <- "Sales workers"
mydata$m_s8q12_other__1[1155] <- "Labourers in mining, construction, manufacturing and transport"
mydata$m_s8q12_other__1[1163] <- "Sales workers"
mydata$m_s8q12_other__1[1380] <- "Sales workers"
mydata$m_s8q12_other__1[1430] <- "Sales workers"
mydata$m_s8q12_other__1[1466] <- "Sales workers"
mydata$m_s8q12_other__1[1468] <- "Sales workers"
mydata$m_s8q12_other__1[1469] <- "Sales workers"
mydata$m_s8q12_other__1[1470] <- "Information and communications technology professionals"
mydata$m_s8q12_other__1[1690] <- "Handicraft and printing workers"
mydata$m_s8q12_other__1[1699] <- "Sales workers"
mydata$m_s8q12_other__1[1739] <- "Sales workers"
mydata$m_s8q12_other__1[2223] <- "Sales workers"
mydata$m_s8q12_other__2[942] <- "[language]"
mydata$m_s8q12_other__2[1130] <- "Sales workers"
mydata$m_s8q21_other__1[89] <- "Food processing, wood working, garment and other craft and related trades workers"
mydata$m_s8q21_other__1[129] <- "Sales workers"
mydata$m_s8q21_other__1[149] <- "Sales workers"
mydata$m_s8q21_other__1[244] <- "Sales workers"
mydata$m_s8q21_other__1[347] <- "Sales workers"
mydata$m_s8q21_other__1[952] <- "Other"
mydata$m_s8q21_other__1[1214] <- "Sales workers"
mydata$m_s8q21_other__1[1244] <- "Sales workers"
mydata$m_s8q21_other__1[1275] <- "Sales workers"
mydata$m_s8q21_other__1[1277] <- "Sales workers"
mydata$m_s8q21_other__1[1324] <- "Sales workers"
mydata$m_s8q21_other__1[1468] <- "Sales workers"
mydata$m_s8q25_other__1[749] <- "[language]"
mydata$m_endnote8__3[327] <- "[language]"
mydata$m_endnote8__1[253] <- "[language]"
mydata$m_endnote8__1[261] <- "They just close the business to avoid [language]"
mydata$m_endnote8__1[262] <- "[language]"
mydata$m_endnote8__1[286] <- "[language]"
mydata$m_endnote8__1[302] <- "[language]"
mydata$m_endnote8__1[303] <- "[language]"
mydata$m_endnote8__1[305] <- "[name] selling fish started last February for 2 weeks And she just recieved her DOLE livelihood program last Wednesday. She said that she just wait for timing and restart her fish vending business."
mydata$m_endnote8__1[318] <- "[name] said that she closed her fishball vending because of her youngest son. [languages]"
mydata$m_endnote8__1[749] <- "[language]"
mydata$m_endnote8__1[1220] <- "They used to sell goods to the canteen where [name] is working but when class closes, same with the canteen, so the business stopped. But they managed to put up an online shop using [name] fb account, using the profit they earned in selling rice. Also, this year they started to cater people with bulk orders of packed meals using the downpayment given by the customers."
# !!!Remove, as it contains sensitive information
mydata <- mydata[!names(mydata) %in% "m_s8_new_name__1"]
mydata <- mydata[!names(mydata) %in% "m_s8_new_name__2"]
mydata <- mydata[!names(mydata) %in% "m_s8_new_name__3"]
mydata <- mydata[!names(mydata) %in% "m_s8_expand_name__1"]
mydata <- mydata[!names(mydata) %in% "m_s8_expand_name__2"]
mydata <- mydata[!names(mydata) %in% "m_s8_close_name__1"]
mydata <- mydata[!names(mydata) %in% "m_s8_close_name__2"]
mydata <- mydata[!names(mydata) %in% "m_s8_close_name__3"]
# !!!No GPS data
haven::write_dta(mydata, paste0(filename, "_PU.dta"))
haven::write_sav(mydata, paste0(filename, "_PU.sav"))
# Add report title dynamically
title_var <- paste0("DOL-ILAB SDC - ", filename)