rm(list=ls(all=t))

Setup filenames

filename <- "Section_6" # !!!Update filename
functions_vers <-  "functions_1.8.R" # !!!Update helper functions file

Setup data, functions and create dictionary for dataset review

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 

Direct PII: variables to be removed

# !!!No Direct PII

Direct PII-team: Encode field team names

# !!!No Direct PII-team

Small locations: Encode locations with pop <100,000 using random large numbers

# !!!No small locations

Indirect PII - Ordinal: Global recode or Top/bottom coding for extreme values

# Focus on variables with a "Lowest Freq" in dictionary of 30 or less. 

mydata <- top_recode ("s6q12count", break_point=4, missing=c(888, 999999))  
## [1] "Frequency table before encoding"
## s6q12count. How many crops did you grow In the last 12 months?  Ilang panahim ang iyong tina
##    0    1    2    3    4    5    6   10   19 <NA> 
##    4  302  124   42   29   22    8    1    1 1763

## [1] "Frequency table after encoding"
## s6q12count. How many crops did you grow In the last 12 months?  Ilang panahim ang iyong tina
##         0         1         2         3 4 or more      <NA> 
##         4       302       124        42        61      1763

# Top code high values to the 99.5 percentile
percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q2)[na.exclude(mydata$s6q2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q2. How many units is this land?  Ilang pangkat ang lupang ito?
##     0     1     2     3     4     5     6     7     8    10    12    15    16    18    20    24    25    30 
##     4    38     9     6     2     1     1     1     2     2     1     2     3     1     3     1     7     6 
##    33    35    40    41    42    45    46    47    48    50    54    56    57    60    63    64    70    72 
##     1     4     6     1     2     2     1     1     3    20     1     2     1    14     1     1     2     2 
##    75    80    84    90    95    96   100   104   105   108   117   120   135   140   144   147   150   168 
##     2     9     1     4     2     2    30     1     2     1     1     7     1     1     2     2    18     3 
##   180   200   218   220   225   238   240   250   255   278   288   300   308   330   360   386   393   400 
##     4    11     1     1     5     1     2     8     1     1     2    14     1     1     2     1     1     6 
##   406   430   450   481   499   500   600   624   695   700   750   800   840   900   996  1000  1200  1300 
##     1     1     3     1     1    10     6     1     1     1     1     3     1     2     1     2     1     1 
##  1424  1500  1575  1800  1884  2000  2500  3000  4000  5000  6250  7000  8000 15000  <NA> 
##     1     3     1     1     1     3     6     1     2     9     1     1     3     1  1917

## [1] "Frequency table after encoding"
## s6q2. How many units is this land?  Ilang pangkat ang lupang ito?
##            0            1            2            3            4            5            6            7 
##            4           38            9            6            2            1            1            1 
##            8           10           12           15           16           18           20           24 
##            2            2            1            2            3            1            3            1 
##           25           30           33           35           40           41           42           45 
##            7            6            1            4            6            1            2            2 
##           46           47           48           50           54           56           57           60 
##            1            1            3           20            1            2            1           14 
##           63           64           70           72           75           80           84           90 
##            1            1            2            2            2            9            1            4 
##           95           96          100          104          105          108          117          120 
##            2            2           30            1            2            1            1            7 
##          135          140          144          147          150          168          180          200 
##            1            1            2            2           18            3            4           11 
##          218          220          225          238          240          250          255          278 
##            1            1            5            1            2            8            1            1 
##          288          300          308          330          360          386          393          400 
##            2           14            1            1            2            1            1            6 
##          406          430          450          481          499          500          600          624 
##            1            1            3            1            1           10            6            1 
##          695          700          750          800          840          900          996         1000 
##            1            1            1            3            1            2            1            2 
##         1200         1300         1424         1500         1575         1800         1884         2000 
##            1            1            1            3            1            1            1            3 
##         2500         3000         4000         5000         6250         7000 8000 or more         <NA> 
##            6            1            2            9            1            1            4         1917

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q4a)[na.exclude(mydata$s6q4a)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q4a", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q4a. How many units is this land?  Ilang yunits ang lupang ito? 
##     0     1     2     3     4     5     6     7     8    15    20    25    28    30    36    40    50    68 
##     1    44    20     9     4     3     2     2     2     2     1     1     1     4     1     3     2     1 
##    75    96    98   100   105   150   200   250   280   384   406   500   510   700  1000  1500  1600  1800 
##     1     1     1     5     1     2     3     5     2     1     1    11     1     1     3     3     1     1 
##  2000  2400  2500  3000  5000  5800  6000  6500  7000  7500 10000 13000 14000 15000  <NA> 
##     1     1     8     1    12     1     3     1     3     1     4     1     1     2  2109

## [1] "Frequency table after encoding"
## s6q4a. How many units is this land?  Ilang yunits ang lupang ito? 
##             0             1             2             3             4             5             6 
##             1            44            20             9             4             3             2 
##             7             8            15            20            25            28            30 
##             2             2             2             1             1             1             4 
##            36            40            50            68            75            96            98 
##             1             3             2             1             1             1             1 
##           100           105           150           200           250           280           384 
##             5             1             2             3             5             2             1 
##           406           500           510           700          1000          1500          1600 
##             1            11             1             1             3             3             1 
##          1800          2000          2400          2500          3000          5000          5800 
##             1             1             1             8             1            12             1 
##          6000          6500          7000          7500         10000         13000         14000 
##             3             1             3             1             4             1             1 
## 15000 or more          <NA> 
##             2          2109

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q7)[na.exclude(mydata$s6q7)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q7", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q7. How much did your household pay to rent this land in the last 12 months?  Magkan
##      0    200    305    350    400    440    500    600    950   1000   1320   1500   1545   1800   2000 
##     12      1      1      1      1      1      3      2      1      7      1      2      1      1      6 
##   2063   2100   2200   2400   2500   2800   2880   3000   3125   3300   3750   3900   4000   4032   4200 
##      1      2      1      4      2      1      1      4      1      1      1      1      5      1      1 
##   4800   5000   5208   5250   5525   6000   6720   6800   7000   7200   7320   8182   8700   9350  10000 
##      1      7      1      1      1      2      1      1      1      1      1      1      1      1      2 
##  10800  11200  12000  12600  14000  17600  20000  24000  25000  31000  31775  40000  45000  57600 127500 
##      1      1      1      1      1      1      1      1      1      1      1      1      1      1      1 
##   <NA> 
##   2190

## [1] "Frequency table after encoding"
## s6q7. How much did your household pay to rent this land in the last 12 months?  Magkan
##             0           200           305           350           400           440           500 
##            12             1             1             1             1             1             3 
##           600           950          1000          1320          1500          1545          1800 
##             2             1             7             1             2             1             1 
##          2000          2063          2100          2200          2400          2500          2800 
##             6             1             2             1             4             2             1 
##          2880          3000          3125          3300          3750          3900          4000 
##             1             4             1             1             1             1             5 
##          4032          4200          4800          5000          5208          5250          5525 
##             1             1             1             7             1             1             1 
##          6000          6720          6800          7000          7200          7320          8182 
##             2             1             1             1             1             1             1 
##          8700          9350         10000         10800         11200         12000         12600 
##             1             1             2             1             1             1             1 
##         14000         17600         20000         24000         25000         31000         31775 
##             1             1             1             1             1             1             1 
##         40000         45000         57600 90802 or more          <NA> 
##             1             1             1             1          2190

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q9)[na.exclude(mydata$s6q9)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q9", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q9. What was your household's share as a percentage of output?  Ano ang parte ng iyo
##    0    1    2    3    5    7    8   10   12   13   15   16   17   20   25   30   40   50   60   66   70   75 
##    6    3    1    1    1    1    1   18    2    3    4    1    1    8   10    3    1   25    5    1    9    9 
##   80   83   85   90   91  100 <NA> 
##   12    1    2    6    1   10 2150

## [1] "Frequency table after encoding"
## s6q9. What was your household's share as a percentage of output?  Ano ang parte ng iyo
##           0           1           2           3           5           7           8          10          12 
##           6           3           1           1           1           1           1          18           2 
##          13          15          16          17          20          25          30          40          50 
##           3           4           1           1           8          10           3           1          25 
##          60          66          70          75          80          83          85          90          91 
##           5           1           9           9          12           1           2           6           1 
## 100 or more        <NA> 
##          10        2150

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q9a)[na.exclude(mydata$s6q9a)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q9a", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q9a. How much did your household earn from sharecropping in the last 12 months?  Magk
##      0    200    300    440    500    800   1200   1475   1500   1700   1800   1850   2000   2100   2250 
##     19      1      1      1      1      1      2      1      1      1      1      1      4      1      1 
##   2400   2700   2904   3000   3130   3150   3300   3500   3900   4000   4186   5000   5400   5600   5850 
##      1      1      1      4      1      1      1      2      1      5      1      5      1      1      1 
##   6000   7000   7200   7650   8000   8400   9000   9375   9750   9800  10000  11400  11900  12000  12800 
##      5      2      1      1      6      1      3      1      1      1      8      1      1      4      1 
##  13000  13500  14000  14480  15000  15300  16000  17000  17500  18000  18720  18900  19200  19500  20000 
##      1      1      1      1      1      1      1      1      1      2      1      1      1      1      6 
##  20418  22500  24000  25000  25500  27000  29124  29750  30000  32000  34000  36000  37350  38500  38640 
##      1      1      1      1      1      1      1      1      4      2      1      1      1      1      1 
##  45750  50000  70000  72000  80000  82800 168000   <NA> 
##      1      1      1      1      1      1      1   2148

## [1] "Frequency table after encoding"
## s6q9a. How much did your household earn from sharecropping in the last 12 months?  Magk
##              0            200            300            440            500            800           1200 
##             19              1              1              1              1              1              2 
##           1475           1500           1700           1800           1850           2000           2100 
##              1              1              1              1              1              4              1 
##           2250           2400           2700           2904           3000           3130           3150 
##              1              1              1              1              4              1              1 
##           3300           3500           3900           4000           4186           5000           5400 
##              1              2              1              5              1              5              1 
##           5600           5850           6000           7000           7200           7650           8000 
##              1              1              5              2              1              1              6 
##           8400           9000           9375           9750           9800          10000          11400 
##              1              3              1              1              1              8              1 
##          11900          12000          12800          13000          13500          14000          14480 
##              1              4              1              1              1              1              1 
##          15000          15300          16000          17000          17500          18000          18720 
##              1              1              1              1              1              2              1 
##          18900          19200          19500          20000          20418          22500          24000 
##              1              1              1              6              1              1              1 
##          25000          25500          27000          29124          29750          30000          32000 
##              1              1              1              1              1              4              2 
##          34000          36000          37350          38500          38640          45750          50000 
##              1              1              1              1              1              1              1 
##          70000          72000          80000          82800 105377 or more           <NA> 
##              1              1              1              1              1           2148

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q11)[na.exclude(mydata$s6q11)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q11", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q11. How much did your household receive as rental payment for this land in the last 
##     0   200   800  1000  4000  5000 45000 60000  <NA> 
##     2     1     1     2     1     1     1     1  2286

## [1] "Frequency table after encoding"
## s6q11. How much did your household receive as rental payment for this land in the last 
##             0           200           800          1000          4000          5000         45000 
##             2             1             1             2             1             1             1 
## 59325 or more          <NA> 
##             1          2286

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q17_1)[na.exclude(mydata$s6q17_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q17_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q17_1. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##      0     84     90    100    120    150    200    220    250    300    450    500    574    600    750 
##      4      1      2      4      1      1      3      2      3      2      1      4      1      4      1 
##    776    800    860    900    950   1000   1050   1085   1100   1150   1200   1300   1500   1545   1580 
##      1      1      1      3      1     12      1      1      1      1      4      1     11      1      1 
##   1600   2000   2160   2250   2300   2400   2500   2800   3000   3400   3500   3940   4000   4500   4650 
##      1     17      1      1      1      2      3      1     17      1      2      1     11      3      1 
##   5000   5800   6000   6350   6600   6750   7000   8000   9000   9800  10000  10250  10500  12000  12750 
##     34      1      8      1      1      1      4      2      2      1     37      1      1      8      1 
##  13000  14000  15000  15690  16600  18800  20000  21000  24160  25000  27000  28000  30000  31000  33000 
##      2      2     14      1      1      1     16      1      1     10      1      1     14      1      1 
##  35000  37500  40000  42000  42400  48000  50000  65000  66000  80000  1e+05 180000  2e+05   <NA> 
##      1      1      4      1      1      1      1      1      1      3      1      1      1   1970

## [1] "Frequency table after encoding"
## s6q17_1. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##              0             84             90            100            120            150            200 
##              4              1              2              4              1              1              3 
##            220            250            300            450            500            574            600 
##              2              3              2              1              4              1              4 
##            750            776            800            860            900            950           1000 
##              1              1              1              1              3              1             12 
##           1050           1085           1100           1150           1200           1300           1500 
##              1              1              1              1              4              1             11 
##           1545           1580           1600           2000           2160           2250           2300 
##              1              1              1             17              1              1              1 
##           2400           2500           2800           3000           3400           3500           3940 
##              2              3              1             17              1              2              1 
##           4000           4500           4650           5000           5800           6000           6350 
##             11              3              1             34              1              8              1 
##           6600           6750           7000           8000           9000           9800          10000 
##              1              1              4              2              2              1             37 
##          10250          10500          12000          12750          13000          14000          15000 
##              1              1              8              1              2              2             14 
##          15690          16600          18800          20000          21000          24160          25000 
##              1              1              1             16              1              1             10 
##          27000          28000          30000          31000          33000          35000          37500 
##              1              1             14              1              1              1              1 
##          40000          42000          42400          48000          50000          65000          66000 
##              4              1              1              1              1              1              1 
##          80000          1e+05 130000 or more           <NA> 
##              3              1              2           1970

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q19_1)[na.exclude(mydata$s6q19_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q19_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q19_1. What is the quantity of the crop harvested in the last 12 months? Please give th
##      0      1      2      3      4      5      6      7      8     10     11     12     13     14     15 
##     13     19     14     12      7      6     10      8     10     24      4      4      2      4     13 
##     16     17     18     19     20     21     22     24     25     26     27     28     30     31     32 
##      3      2      5      1     16      6      4      5      6      2      5      2     17      2      4 
##     33     35     36     37     38     39     40     41     42     43     44     45     47     48     50 
##      1      4      2      1      1      1     18      2      2      1      2      3      2      1     23 
##     51     56     58     59     60     61     62     63     64     65     66     68     69     70     73 
##      1      4      2      1      9      1      1      1      1      1      1      1      2      8      1 
##     74     75     77     79     80     85     86     88     90     93     94     95     99    100    105 
##      1      1      1      1     10      2      1      1      2      1      1      1      1     25      2 
##    110    111    114    120    140    144    150    153    158    160    168    175    180    192    200 
##      1      1      1      3      1      1      8      1      1      1      1      1      2      1      8 
##    210    223    240    268    280    288    300    310    350    360    370    385    400    431    480 
##      1      1      4      1      1      1      7      1      1      2      1      1      1      1      1 
##    500    560    576    590    600    700    767    800    864    900   1000   1200   1333   1500   1590 
##      6      1      1      1      2      2      1      3      1      1      9      1      1      3      1 
##   1750   1800   2000   2400   2582   3000   3250   3500   4000   4500   5000   6000   6400   8100   8775 
##      1      3      4      2      1      4      1      1      1      1      4      2      1      1      1 
##   9000  10000  11200  12000  13200  14000  18000  19200  20000  21000  24000  25000  30800  32000  35000 
##      1      3      1      2      1      1      1      1      2      1      2      1      1      1      1 
##  36000  50000  60000 133000 277500   <NA> 
##      1      1      1      1      1   1772

## [1] "Frequency table after encoding"
## s6q19_1. What is the quantity of the crop harvested in the last 12 months? Please give th
##             0             1             2             3             4             5             6 
##            13            19            14            12             7             6            10 
##             7             8            10            11            12            13            14 
##             8            10            24             4             4             2             4 
##            15            16            17            18            19            20            21 
##            13             3             2             5             1            16             6 
##            22            24            25            26            27            28            30 
##             4             5             6             2             5             2            17 
##            31            32            33            35            36            37            38 
##             2             4             1             4             2             1             1 
##            39            40            41            42            43            44            45 
##             1            18             2             2             1             2             3 
##            47            48            50            51            56            58            59 
##             2             1            23             1             4             2             1 
##            60            61            62            63            64            65            66 
##             9             1             1             1             1             1             1 
##            68            69            70            73            74            75            77 
##             1             2             8             1             1             1             1 
##            79            80            85            86            88            90            93 
##             1            10             2             1             1             2             1 
##            94            95            99           100           105           110           111 
##             1             1             1            25             2             1             1 
##           114           120           140           144           150           153           158 
##             1             3             1             1             8             1             1 
##           160           168           175           180           192           200           210 
##             1             1             1             2             1             8             1 
##           223           240           268           280           288           300           310 
##             1             4             1             1             1             7             1 
##           350           360           370           385           400           431           480 
##             1             2             1             1             1             1             1 
##           500           560           576           590           600           700           767 
##             6             1             1             1             2             2             1 
##           800           864           900          1000          1200          1333          1500 
##             3             1             1             9             1             1             3 
##          1590          1750          1800          2000          2400          2582          3000 
##             1             1             3             4             2             1             4 
##          3250          3500          4000          4500          5000          6000          6400 
##             1             1             1             1             4             2             1 
##          8100          8775          9000         10000         11200         12000         13200 
##             1             1             1             3             1             2             1 
##         14000         18000         19200         20000         21000         24000         25000 
##             1             1             1             2             1             2             1 
##         30800         32000         35000         36000         50000 53849 or more          <NA> 
##             1             1             1             1             1             3          1772

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q20_1)[na.exclude(mydata$s6q20_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q20_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q20_1. What is the total market value of the quantity harvested in the last 12 months? 
##      0     10     11     15     16     20     30     31     50     90    100    105    135    150    168 
##     14      2      1      1      1      1      1      1      2      1      2      1      1      2      1 
##    180    200    225    240    250    300    360    375    400    417    450    500    525    544    600 
##      1      3      1      2      1      8      1      1      4      1      1      7      1      1      2 
##    629    660    700    720    750    784    795    800    820    900    920    950    980   1000   1050 
##      1      1      2      2      2      1      1      1      1      3      1      2      1      7      1 
##   1120   1200   1250   1280   1300   1350   1360   1400   1440   1500   1560   1600   1740   1755   1800 
##      2      1      1      1      1      1      1      1      1     10      1      1      1      1      4 
##   1980   2000   2025   2145   2240   2250   2300   2400   2432   2500   2700   3000   3060   3120   3200 
##      1      7      1      1      1      1      1      5      1      4      1      6      2      1      1 
##   3360   3450   3500   3600   3700   3760   4000   4200   4320   4500   4608   4680   4800   4900   5000 
##      2      1      5      1      1      1      6      1      1      1      1      1      1      3      7 
##   5500   5600   5920   5985   5986   6000   6050   6100   6300   6400   6438   6500   6825   6900   7000 
##      1      2      1      1      1      9      1      1      3      1      1      3      1      1      2 
##   7200   7425   7500   8000   8250   8450   8704   8772   9000   9350   9500   9625   9800   9984  10000 
##      2      1      2      9      1      1      1      1      8      1      2      1      1      1      6 
##  10200  10500  10556  10944  11000  11040  11250  11500  11505  11600  11900  12000  12168  12288  12440 
##      1      3      1      1      2      1      1      1      1      1      1     11      1      1      1 
##  12500  12600  12960  13000  13120  13156  13200  13300  13800  14000  14560  15000  15120  15300  15600 
##      1      1      2      1      1      1      1      1      1      3      1      2      2      1      1 
##  16150  16200  16500  16800  16905  17280  17550  17600  17640  18000  18600  18900  19200  19500  19840 
##      1      1      1      3      1      1      1      1      1      4      1      2      4      2      1 
##  20000  20800  20832  21000  21060  21600  22000  22320  22344  22400  22500  22680  23400  24000  24050 
##      8      1      1      2      1      2      1      1      1      2      4      1      1      4      1 
##  24518  24960  25000  25200  25819  26000  26190  26312  26400  26464  26565  26600  27000  27300  28000 
##      1      1      1      1      1      2      1      1      2      1      1      1      5      1      1 
##  28500  29000  29750  30000  30132  30800  31000  31110  31320  31500  32000  32300  32480  33000  33331 
##      1      2      1      3      1      1      1      1      1      1      5      1      1      1      1 
##  33600  34000  34500  35000  35400  36000  37500  37856  38000  38250  39000  39990  40000  40800  41400 
##      2      1      1      2      1      3      2      1      1      1      2      1      2      2      1 
##  42000  45000  45750  45800  46116  46200  47376  47500  47600  48000  48600  50000  50400  52000  52091 
##      3      1      1      1      1      2      1      1      1      2      1      3      1      3      1 
##  52500  53000  53760  54000  54400  55000  56000  58212  58500  59500  59800  60000  60060  60885  62100 
##      1      1      1      2      1      2      1      1      1      1      1      2      1      1      1 
##  62400  62480  63000  63200  64416  64500  72000  73080  75000  75600  79800  80000  81000  84000  85000 
##      1      1      1      1      1      1      2      1      1      1      1      2      1      1      1 
##  87500  93795 100800 110160 111000 119700 120000 125568 130000 134300 144000 150000 153600 173940 175000 
##      1      1      1      1      1      1      1      1      1      1      1      3      1      1      1 
## 186000 210000 277500 340000 343750 413000 450000 455000 540000   <NA> 
##      1      1      1      1      1      1      1      1      1   1786

## [1] "Frequency table after encoding"
## s6q20_1. What is the total market value of the quantity harvested in the last 12 months? 
##              0             10             11             15             16             20             30 
##             14              2              1              1              1              1              1 
##             31             50             90            100            105            135            150 
##              1              2              1              2              1              1              2 
##            168            180            200            225            240            250            300 
##              1              1              3              1              2              1              8 
##            360            375            400            417            450            500            525 
##              1              1              4              1              1              7              1 
##            544            600            629            660            700            720            750 
##              1              2              1              1              2              2              2 
##            784            795            800            820            900            920            950 
##              1              1              1              1              3              1              2 
##            980           1000           1050           1120           1200           1250           1280 
##              1              7              1              2              1              1              1 
##           1300           1350           1360           1400           1440           1500           1560 
##              1              1              1              1              1             10              1 
##           1600           1740           1755           1800           1980           2000           2025 
##              1              1              1              4              1              7              1 
##           2145           2240           2250           2300           2400           2432           2500 
##              1              1              1              1              5              1              4 
##           2700           3000           3060           3120           3200           3360           3450 
##              1              6              2              1              1              2              1 
##           3500           3600           3700           3760           4000           4200           4320 
##              5              1              1              1              6              1              1 
##           4500           4608           4680           4800           4900           5000           5500 
##              1              1              1              1              3              7              1 
##           5600           5920           5985           5986           6000           6050           6100 
##              2              1              1              1              9              1              1 
##           6300           6400           6438           6500           6825           6900           7000 
##              3              1              1              3              1              1              2 
##           7200           7425           7500           8000           8250           8450           8704 
##              2              1              2              9              1              1              1 
##           8772           9000           9350           9500           9625           9800           9984 
##              1              8              1              2              1              1              1 
##          10000          10200          10500          10556          10944          11000          11040 
##              6              1              3              1              1              2              1 
##          11250          11500          11505          11600          11900          12000          12168 
##              1              1              1              1              1             11              1 
##          12288          12440          12500          12600          12960          13000          13120 
##              1              1              1              1              2              1              1 
##          13156          13200          13300          13800          14000          14560          15000 
##              1              1              1              1              3              1              2 
##          15120          15300          15600          16150          16200          16500          16800 
##              2              1              1              1              1              1              3 
##          16905          17280          17550          17600          17640          18000          18600 
##              1              1              1              1              1              4              1 
##          18900          19200          19500          19840          20000          20800          20832 
##              2              4              2              1              8              1              1 
##          21000          21060          21600          22000          22320          22344          22400 
##              2              1              2              1              1              1              2 
##          22500          22680          23400          24000          24050          24518          24960 
##              4              1              1              4              1              1              1 
##          25000          25200          25819          26000          26190          26312          26400 
##              1              1              1              2              1              1              2 
##          26464          26565          26600          27000          27300          28000          28500 
##              1              1              1              5              1              1              1 
##          29000          29750          30000          30132          30800          31000          31110 
##              2              1              3              1              1              1              1 
##          31320          31500          32000          32300          32480          33000          33331 
##              1              1              5              1              1              1              1 
##          33600          34000          34500          35000          35400          36000          37500 
##              2              1              1              2              1              3              2 
##          37856          38000          38250          39000          39990          40000          40800 
##              1              1              1              2              1              2              2 
##          41400          42000          45000          45750          45800          46116          46200 
##              1              3              1              1              1              1              2 
##          47376          47500          47600          48000          48600          50000          50400 
##              1              1              1              2              1              3              1 
##          52000          52091          52500          53000          53760          54000          54400 
##              3              1              1              1              1              2              1 
##          55000          56000          58212          58500          59500          59800          60000 
##              2              1              1              1              1              1              2 
##          60060          60885          62100          62400          62480          63000          63200 
##              1              1              1              1              1              1              1 
##          64416          64500          72000          73080          75000          75600          79800 
##              1              1              2              1              1              1              1 
##          80000          81000          84000          85000          87500          93795         100800 
##              2              1              1              1              1              1              1 
##         110160         111000         119700         120000         125568         130000         134300 
##              1              1              1              1              1              1              1 
##         144000         150000         153600         173940         175000         186000         210000 
##              1              3              1              1              1              1              1 
##         277500         340000         343750         413000 429834 or more           <NA> 
##              1              1              1              1              3           1786

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q21_1)[na.exclude(mydata$s6q21_1)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q21_1", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q21_1. What was the total revenue received from this crop harvest (sold in market trans
##      0     20     74     75    100    105    135    140    150    200    240    250    300    320    330 
##    124      1      1      1      2      1      1      1      4      1      1      1      3      1      1 
##    360    375    400    417    475    480    500    525    600    700    720    800    840    920    930 
##      1      1      1      1      1      1      4      1      4      1      2      3      1      1      2 
##   1000   1040   1120   1280   1360   1400   1500   1560   1590   1600   1740   1750   1800   2000   2320 
##     13      1      2      2      1      1      7      1      1      2      1      1      6     12      1 
##   2400   2500   2565   2600   2625   2640   2700   2765   2800   2950   2980   2990   3000   3120   3200 
##      1      3      1      1      1      1      2      1      1      1      1      1     11      1      1 
##   3290   3500   3700   3900   4000   4140   4186   4200   4500   4690   4800   4900   5000   5103   5400 
##      1      6      1      1      8      1      1      1      3      1      1      3     10      1      2 
##   5500   5986   6000   6090   6250   6500   6688   6750   7000   7200   7425   7500   7650   8000   8500 
##      2      1      4      1      1      1      1      1      3      1      1      4      1      3      1 
##   9000   9360   9450   9500   9600   9800  10000  10400  10500  10800  10944  11000  11100  11200  11500 
##      4      1      2      1      2      1     11      1      1      1      1      2      1      1      1 
##  11885  12000  12600  13156  13200  13650  13800  14000  14250  14400  14560  15000  15288  16000  16100 
##      1     13      1      1      1      1      1      2      1      1      1      6      1      1      1 
##  16150  16200  16800  16905  17000  18000  18500  18846  19000  19200  19300  19440  19500  20000  20160 
##      1      1      1      1      2      4      1      1      1      1      1      1      2      7      1 
##  20800  20832  21000  22000  22320  22680  22875  23680  24000  24464  25000  25200  25500  25616  25819 
##      1      1      2      1      1      1      1      1      3      1      2      2      1      1      1 
##  26364  26400  26565  27000  29000  29750  30000  31000  31110  31500  32000  33331  33500  33600  34000 
##      1      1      1      4      1      1      5      1      1      1      2      1      1      1      2 
##  35400  36000  37500  37800  38500  39000  39600  40000  40320  40800  41000  42000  43750  45000  46080 
##      1      2      2      1      2      1      1      3      1      1      1      1      1      1      1 
##  47500  48000  48600  48608  50000  50250  50880  51040  52500  52780  53000  58000  58212  58500  60000 
##      1      1      1      1      4      1      1      1      1      1      1      1      1      1      3 
##  62100  64000  64416  66000  70000  74400  76000  78000  82800  83778  87500  91800 100800 115300 116220 
##      1      1      1      1      2      1      1      1      1      1      1      1      1      1      1 
## 120000 125568 140000 150000 206250 450000 455000 540000   <NA> 
##      1      1      1      2      1      1      1      1   1781

## [1] "Frequency table after encoding"
## s6q21_1. What was the total revenue received from this crop harvest (sold in market trans
##              0             20             74             75            100            105            135 
##            124              1              1              1              2              1              1 
##            140            150            200            240            250            300            320 
##              1              4              1              1              1              3              1 
##            330            360            375            400            417            475            480 
##              1              1              1              1              1              1              1 
##            500            525            600            700            720            800            840 
##              4              1              4              1              2              3              1 
##            920            930           1000           1040           1120           1280           1360 
##              1              2             13              1              2              2              1 
##           1400           1500           1560           1590           1600           1740           1750 
##              1              7              1              1              2              1              1 
##           1800           2000           2320           2400           2500           2565           2600 
##              6             12              1              1              3              1              1 
##           2625           2640           2700           2765           2800           2950           2980 
##              1              1              2              1              1              1              1 
##           2990           3000           3120           3200           3290           3500           3700 
##              1             11              1              1              1              6              1 
##           3900           4000           4140           4186           4200           4500           4690 
##              1              8              1              1              1              3              1 
##           4800           4900           5000           5103           5400           5500           5986 
##              1              3             10              1              2              2              1 
##           6000           6090           6250           6500           6688           6750           7000 
##              4              1              1              1              1              1              3 
##           7200           7425           7500           7650           8000           8500           9000 
##              1              1              4              1              3              1              4 
##           9360           9450           9500           9600           9800          10000          10400 
##              1              2              1              2              1             11              1 
##          10500          10800          10944          11000          11100          11200          11500 
##              1              1              1              2              1              1              1 
##          11885          12000          12600          13156          13200          13650          13800 
##              1             13              1              1              1              1              1 
##          14000          14250          14400          14560          15000          15288          16000 
##              2              1              1              1              6              1              1 
##          16100          16150          16200          16800          16905          17000          18000 
##              1              1              1              1              1              2              4 
##          18500          18846          19000          19200          19300          19440          19500 
##              1              1              1              1              1              1              2 
##          20000          20160          20800          20832          21000          22000          22320 
##              7              1              1              1              2              1              1 
##          22680          22875          23680          24000          24464          25000          25200 
##              1              1              1              3              1              2              2 
##          25500          25616          25819          26364          26400          26565          27000 
##              1              1              1              1              1              1              4 
##          29000          29750          30000          31000          31110          31500          32000 
##              1              1              5              1              1              1              2 
##          33331          33500          33600          34000          35400          36000          37500 
##              1              1              1              2              1              2              2 
##          37800          38500          39000          39600          40000          40320          40800 
##              1              2              1              1              3              1              1 
##          41000          42000          43750          45000          46080          47500          48000 
##              1              1              1              1              1              1              1 
##          48600          48608          50000          50250          50880          51040          52500 
##              1              1              4              1              1              1              1 
##          52780          53000          58000          58212          58500          60000          62100 
##              1              1              1              1              1              3              1 
##          64000          64416          66000          70000          74400          76000          78000 
##              1              1              1              2              1              1              1 
##          82800          83778          87500          91800         100800         115300         116220 
##              1              1              1              1              1              1              1 
##         120000         125568         140000         150000         206250 311062 or more           <NA> 
##              1              1              1              2              1              3           1781

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q17_2)[na.exclude(mydata$s6q17_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q17_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q17_2. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##     0    40    50    56    90   100   150   200   250   300   400   500   525   600   750   776   800   860 
##     5     2     1     1     1     2     1     1     1     1     4     2     1     1     1     1     1     1 
##  1000  1400  2000  2200  2350  2500  3000  3720  4000  5000  5350  5500  7000  7500  7600  8180 10000 10616 
##     4     2    10     1     1     2     1     1     4    10     1     1     1     1     1     1     6     1 
## 11740 12000 13000 15000 18000 18660 19000 20000 21000 23000 24000 30000 40000 50000 52000 60000 81000  <NA> 
##     1     1     1     6     1     1     1     2     1     1     1     5     2     2     1     1     1  2190

## [1] "Frequency table after encoding"
## s6q17_2. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##             0            40            50            56            90           100           150 
##             5             2             1             1             1             2             1 
##           200           250           300           400           500           525           600 
##             1             1             1             4             2             1             1 
##           750           776           800           860          1000          1400          2000 
##             1             1             1             1             4             2            10 
##          2200          2350          2500          3000          3720          4000          5000 
##             1             1             2             1             1             4            10 
##          5350          5500          7000          7500          7600          8180         10000 
##             1             1             1             1             1             1             6 
##         10616         11740         12000         13000         15000         18000         18660 
##             1             1             1             1             6             1             1 
##         19000         20000         21000         23000         24000         30000         40000 
##             1             2             1             1             1             5             2 
##         50000         52000         60000 69974 or more          <NA> 
##             2             1             1             1          2190

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q19_2)[na.exclude(mydata$s6q19_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q19_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q19_2. What is the quantity of the crop harvested in the last 12 months? Please give th
##      0      1      2      3      4      5      6      7      8      9     10     11     12     14     15 
##     19     11      8      9      4      5      1      3      5      2      6      2      1      1      6 
##     16     17     18     19     20     21     25     26     27     30     32     33     34     35     39 
##      1      1      4      1     15      1      2      1      1      6      1      1      1      1      1 
##     40     45     46     48     49     50     53     55     60     61     69     70     74     75     80 
##      4      1      1      1      1     13      1      1      2      1      1      1      1      1      2 
##     90     96     97    100    120    130    135    140    150    160    180    200    220    240    250 
##      2      1      1     10      1      1      1      1      4      2      1      3      1      1      1 
##    252    300    320    365    400    480    500    600    630    714    720    750    800   1000   1200 
##      1      6      1      1      2      1      4      2      1      1      1      1      2      1      1 
##   2000   3000   3750   4000   5500   6000   7500   9000  13500  19000  45000  50000 250000   <NA> 
##      1      3      1      1      1      1      1      1      1      1      1      1      1   2071

## [1] "Frequency table after encoding"
## s6q19_2. What is the quantity of the crop harvested in the last 12 months? Please give th
##             0             1             2             3             4             5             6 
##            19            11             8             9             4             5             1 
##             7             8             9            10            11            12            14 
##             3             5             2             6             2             1             1 
##            15            16            17            18            19            20            21 
##             6             1             1             4             1            15             1 
##            25            26            27            30            32            33            34 
##             2             1             1             6             1             1             1 
##            35            39            40            45            46            48            49 
##             1             1             4             1             1             1             1 
##            50            53            55            60            61            69            70 
##            13             1             1             2             1             1             1 
##            74            75            80            90            96            97           100 
##             1             1             2             2             1             1            10 
##           120           130           135           140           150           160           180 
##             1             1             1             1             4             2             1 
##           200           220           240           250           252           300           320 
##             3             1             1             1             1             6             1 
##           365           400           480           500           600           630           714 
##             1             2             1             4             2             1             1 
##           720           750           800          1000          1200          2000          3000 
##             1             1             2             1             1             1             3 
##          3750          4000          5500          6000          7500          9000         13500 
##             1             1             1             1             1             1             1 
##         19000         45000 49399 or more          <NA> 
##             1             1             2          2071

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q20_2)[na.exclude(mydata$s6q20_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q20_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q20_2. What is the total market value of the quantity harvested in the last 12 months? 
##      0      5     20     25     35     40     50     60     70     80    100    135    150    200    250 
##     19      1      2      1      1      2      2      2      1      2      1      1      4      1      1 
##    300    350    360    400    473    480    500    600    640    700    720    750    770    800    900 
##      7      2      1      8      1      1      5      1      1      3      1      2      1      4      1 
##   1000   1200   1250   1350   1400   1500   1600   1680   1750   1783   1800   1856   2000   2400   2800 
##      5      4      1      1      1      5      2      1      1      1      1      1      6      2      1 
##   2880   3000   3120   3200   3500   3600   3720   4050   4200   4500   5000   5200   5500   5986   6000 
##      1      3      1      1      1      1      1      1      1      2      3      1      2      1      7 
##   6250   6330   6400   7000   7020   7290   7500   7800   8000   8280   8400   8550   9000   9600  10000 
##      1      1      2      1      1      1      1      1      5      1      1      1      2      1      2 
##  10800  11700  11760  11808  11880  12000  12020  12500  12750  13500  15000  15232  15980  18000  20000 
##      1      1      1      1      1      4      1      1      1      1      1      1      1      1      1 
##  20250  21600  23750  24000  25000  26400  26950  27258  28000  30000  33000  36000  40000  40320  42000 
##      1      1      1      2      1      1      1      1      1      2      1      1      1      1      1 
##  43200  45000  45540  50000  50880  52000  55000  62050  63000  70000  72000  75600  78104  80000  81250 
##      1      3      1      3      1      1      1      1      1      1      1      1      1      1      1 
## 130000 192800   <NA> 
##      1      1   2078

## [1] "Frequency table after encoding"
## s6q20_2. What is the total market value of the quantity harvested in the last 12 months? 
##              0              5             20             25             35             40             50 
##             19              1              2              1              1              2              2 
##             60             70             80            100            135            150            200 
##              2              1              2              1              1              4              1 
##            250            300            350            360            400            473            480 
##              1              7              2              1              8              1              1 
##            500            600            640            700            720            750            770 
##              5              1              1              3              1              2              1 
##            800            900           1000           1200           1250           1350           1400 
##              4              1              5              4              1              1              1 
##           1500           1600           1680           1750           1783           1800           1856 
##              5              2              1              1              1              1              1 
##           2000           2400           2800           2880           3000           3120           3200 
##              6              2              1              1              3              1              1 
##           3500           3600           3720           4050           4200           4500           5000 
##              1              1              1              1              1              2              3 
##           5200           5500           5986           6000           6250           6330           6400 
##              1              2              1              7              1              1              2 
##           7000           7020           7290           7500           7800           8000           8280 
##              1              1              1              1              1              5              1 
##           8400           8550           9000           9600          10000          10800          11700 
##              1              1              2              1              2              1              1 
##          11760          11808          11880          12000          12020          12500          12750 
##              1              1              1              4              1              1              1 
##          13500          15000          15232          15980          18000          20000          20250 
##              1              1              1              1              1              1              1 
##          21600          23750          24000          25000          26400          26950          27258 
##              1              1              2              1              1              1              1 
##          28000          30000          33000          36000          40000          40320          42000 
##              1              2              1              1              1              1              1 
##          43200          45000          45540          50000          50880          52000          55000 
##              1              3              1              3              1              1              1 
##          62050          63000          70000          72000          75600          78104          80000 
##              1              1              1              1              1              1              1 
##          81250 125856 or more           <NA> 
##              1              2           2078

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q21_2)[na.exclude(mydata$s6q21_2)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q21_2", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q21_2. What was the total revenue received from this crop harvest (sold in market trans
##      0     20     50     60     80    120    135    150    160    200    240    250    280    300    350 
##     65      1      1      1      1      1      1      3      1      2      1      1      2      4      1 
##    360    400    500    600    625    700    800    840   1000   1100   1200   1280   1300   1350   1400 
##      2      2      6      6      1      3      5      1      5      1      4      1      1      1      1 
##   1440   1500   1600   1680   1750   1783   1800   1950   2000   2600   2860   3000   3500   3600   4000 
##      1      4      2      1      1      1      1      1      7      1      1      4      2      1      3 
##   4200   4500   4800   5000   5986   6000   6400   6650   7000   7020   7200   7290   8000   8400   9000 
##      2      1      1      5      1      6      1      1      1      1      2      1      1      1      1 
##   9600  10000  11500  11700  11760  11880  12000  12500  12600  15000  15232  15400  15980  16000  20250 
##      1      3      1      1      1      1      4      1      1      1      1      1      1      1      1 
##  23757  25000  26950  27000  27258  29700  30000  35000  36500  37140  40000  45540  50200  50400  55000 
##      1      1      1      1      1      1      2      1      1      1      4      1      1      2      1 
##  72000  78104  80000 130000 160000   <NA> 
##      1      1      1      1      1   2068

## [1] "Frequency table after encoding"
## s6q21_2. What was the total revenue received from this crop harvest (sold in market trans
##              0             20             50             60             80            120            135 
##             65              1              1              1              1              1              1 
##            150            160            200            240            250            280            300 
##              3              1              2              1              1              2              4 
##            350            360            400            500            600            625            700 
##              1              2              2              6              6              1              3 
##            800            840           1000           1100           1200           1280           1300 
##              5              1              5              1              4              1              1 
##           1350           1400           1440           1500           1600           1680           1750 
##              1              1              1              4              2              1              1 
##           1783           1800           1950           2000           2600           2860           3000 
##              1              1              1              7              1              1              4 
##           3500           3600           4000           4200           4500           4800           5000 
##              2              1              3              2              1              1              5 
##           5986           6000           6400           6650           7000           7020           7200 
##              1              6              1              1              1              1              2 
##           7290           8000           8400           9000           9600          10000          11500 
##              1              1              1              1              1              3              1 
##          11700          11760          11880          12000          12500          12600          15000 
##              1              1              1              4              1              1              1 
##          15232          15400          15980          16000          20250          23757          25000 
##              1              1              1              1              1              1              1 
##          26950          27000          27258          29700          30000          35000          36500 
##              1              1              1              1              2              1              1 
##          37140          40000          45540          50200          50400          55000          72000 
##              1              4              1              1              2              1              1 
##          78104          80000 123250 or more           <NA> 
##              1              1              2           2068

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q17_3)[na.exclude(mydata$s6q17_3)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q17_3", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q17_3. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##     0    50   100   150   200   300   390   500   600   750   776  1000  1350  1800  2000  2780  4000  5000 
##     2     1     1     3     1     2     1     1     1     1     1     2     1     1     1     1     2     2 
##  6000 30000  <NA> 
##     1     1  2269

## [1] "Frequency table after encoding"
## s6q17_3. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##             0            50           100           150           200           300           390 
##             2             1             1             3             1             2             1 
##           500           600           750           776          1000          1350          1800 
##             1             1             1             1             2             1             1 
##          2000          2780          4000          5000          6000 26880 or more          <NA> 
##             1             1             2             2             1             1          2269

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q19_3)[na.exclude(mydata$s6q19_3)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q19_3", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q19_3. What is the quantity of the crop harvested in the last 12 months? Please give th
##      0      1      2      3      4      5      6      7     10     11     15     17     20     30     35 
##     15      4      2      3      4      5      1      2      5      1      3      1      3      6      1 
##     40     48     50     70     72     74     80     90    100    115    160    180    200    300    480 
##      4      2      4      1      1      1      1      1      4      1      1      1      5      5      1 
##    500    540    900   1000   1500   2000   2400   4710   6000   9000 105000   <NA> 
##      1      1      1      3      1      1      1      1      1      1      1   2194

## [1] "Frequency table after encoding"
## s6q19_3. What is the quantity of the crop harvested in the last 12 months? Please give th
##             0             1             2             3             4             5             6 
##            15             4             2             3             4             5             1 
##             7            10            11            15            17            20            30 
##             2             5             1             3             1             3             6 
##            35            40            48            50            70            72            74 
##             1             4             2             4             1             1             1 
##            80            90           100           115           160           180           200 
##             1             1             4             1             1             1             5 
##           300           480           500           540           900          1000          1500 
##             5             1             1             1             1             3             1 
##          2000          2400          4710          6000          9000 56520 or more          <NA> 
##             1             1             1             1             1             1          2194

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q20_3)[na.exclude(mydata$s6q20_3)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q20_3", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q20_3. What is the total market value of the quantity harvested in the last 12 months? 
##      0      5     15     25     30     50     54     60    100    120    125    200    240    300    400 
##     17      1      1      1      1      1      1      1      1      1      1      3      2      3      5 
##    450    500    550    560    700    750    800    900   1000   1080   1150   1190   1200   1440   1500 
##      2      2      2      1      2      1      2      2      5      1      1      1      2      1      1 
##   1700   1800   2000   2200   2400   2500   3000   3500   4000   4070   4500   5000   5250   6000   8400 
##      1      3      4      1      1      2      3      2      2      1      1      3      1      1      1 
##   8800   9000  10000  12000  15200  24000  28800  47100  58500 105000   <NA> 
##      1      1      2      1      1      1      1      1      1      1   2192

## [1] "Frequency table after encoding"
## s6q20_3. What is the total market value of the quantity harvested in the last 12 months? 
##             0             5            15            25            30            50            54 
##            17             1             1             1             1             1             1 
##            60           100           120           125           200           240           300 
##             1             1             1             1             3             2             3 
##           400           450           500           550           560           700           750 
##             5             2             2             2             1             2             1 
##           800           900          1000          1080          1150          1190          1200 
##             2             2             5             1             1             1             2 
##          1440          1500          1700          1800          2000          2200          2400 
##             1             1             1             3             4             1             1 
##          2500          3000          3500          4000          4070          4500          5000 
##             2             3             2             2             1             1             3 
##          5250          6000          8400          8800          9000         10000         12000 
##             1             1             1             1             1             2             1 
##         15200         24000         28800         47100         58500 81052 or more          <NA> 
##             1             1             1             1             1             1          2192

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q21_3)[na.exclude(mydata$s6q21_3)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q21_3", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q21_3. What was the total revenue received from this crop harvest (sold in market trans
##      0     30     50    100    150    200    240    250    300    400    432    440    450    500    600 
##     33      1      1      2      1      4      1      1      2      3      1      1      3      2      2 
##    700    720    800    840    900   1000   1200   1500   1600   1750   1800   2000   2400   2500   3000 
##      2      1      2      1      1      5      2      2      2      1      1      3      1      1      2 
##   3500   4000   4070   4200   4500   5000   5200   5250   9600  10000  11400  12000  24000  47100  58500 
##      1      1      1      1      2      2      1      1      1      2      1      1      1      1      1 
## 110000   <NA> 
##      1   2192

## [1] "Frequency table after encoding"
## s6q21_3. What was the total revenue received from this crop harvest (sold in market trans
##             0            30            50           100           150           200           240 
##            33             1             1             2             1             4             1 
##           250           300           400           432           440           450           500 
##             1             2             3             1             1             3             2 
##           600           700           720           800           840           900          1000 
##             2             2             1             2             1             1             5 
##          1200          1500          1600          1750          1800          2000          2400 
##             2             2             2             1             1             3             1 
##          2500          3000          3500          4000          4070          4200          4500 
##             1             2             1             1             1             1             2 
##          5000          5200          5250          9600         10000         11400         12000 
##             2             1             1             1             2             1             1 
##         24000         47100         58500 83477 or more          <NA> 
##             1             1             1             1          2192

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q17_4)[na.exclude(mydata$s6q17_4)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q17_4", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q17_4. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##   50  150  200  250  300  400  730  750  776 1200 1350 2000 2500 3000 4000 5000 <NA> 
##    1    1    2    1    1    1    1    1    1    1    1    1    1    1    1    1 2279

## [1] "Frequency table after encoding"
## s6q17_4. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##           50          150          200          250          300          400          730          750 
##            1            1            2            1            1            1            1            1 
##          776         1200         1350         2000         2500         3000         4000 4920 or more 
##            1            1            1            1            1            1            1            1 
##         <NA> 
##         2279

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q19_4)[na.exclude(mydata$s6q19_4)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q19_4", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q19_4. What is the quantity of the crop harvested in the last 12 months? Please give th
##      0      1      2      3      5      6      9     10     17     18     20     25     30     40     48 
##      8      4      1      1      4      1      1      3      1      1      4      1      3      1      1 
##     50     90     96    100    143    150    160    180    250    300    400    412    600    720    900 
##      4      1      1      1      1      2      1      1      3      2      1      1      1      1      1 
##   1000   2000 250000   <NA> 
##      2      1      1   2235

## [1] "Frequency table after encoding"
## s6q19_4. What is the quantity of the crop harvested in the last 12 months? Please give th
##              0              1              2              3              5              6              9 
##              8              4              1              1              4              1              1 
##             10             17             18             20             25             30             40 
##              3              1              1              4              1              3              1 
##             48             50             90             96            100            143            150 
##              1              4              1              1              1              1              2 
##            160            180            250            300            400            412            600 
##              1              1              3              2              1              1              1 
##            720            900           1000           2000 175600 or more           <NA> 
##              1              1              2              1              1           2235

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q20_4)[na.exclude(mydata$s6q20_4)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q20_4", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q20_4. What is the total market value of the quantity harvested in the last 12 months? 
##     0    40    50    75    81   120   150   240   250   300   350   400   500   600   750   900   960  1000 
##     7     1     2     1     1     1     2     1     1     3     1     2     2     1     1     1     1     3 
##  1152  1200  1500  1800  2000  2145  2400  2500  3000  3500  3840  4200  5000  6000  6250  7000  8000  8500 
##     1     1     2     1     1     1     2     1     1     1     1     1     2     1     1     1     1     1 
## 10800 12000 18600 21600  <NA> 
##     1     1     1     1  2239

## [1] "Frequency table after encoding"
## s6q20_4. What is the total market value of the quantity harvested in the last 12 months? 
##             0            40            50            75            81           120           150 
##             7             1             2             1             1             1             2 
##           240           250           300           350           400           500           600 
##             1             1             3             1             2             2             1 
##           750           900           960          1000          1152          1200          1500 
##             1             1             1             3             1             1             2 
##          1800          2000          2145          2400          2500          3000          3500 
##             1             1             1             2             1             1             1 
##          3840          4200          5000          6000          6250          7000          8000 
##             1             1             2             1             1             1             1 
##          8500         10800         12000         18600 20759 or more          <NA> 
##             1             1             1             1             1          2239

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q21_4)[na.exclude(mydata$s6q21_4)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q21_4", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q21_4. What was the total revenue received from this crop harvest (sold in market trans
##     0    50    75   120   150   200   240   250   300   400   500   540  1000  1050  1500  1600  1800  2160 
##    16     2     1     1     1     1     1     1     4     2     2     1     4     1     2     1     1     1 
##  2400  2500  2760  2880  3000  3500  3750  4000  6000  7000  7200  8500  8982 11500  <NA> 
##     2     1     1     1     1     1     1     1     1     1     1     1     1     1  2238

## [1] "Frequency table after encoding"
## s6q21_4. What was the total revenue received from this crop harvest (sold in market trans
##             0            50            75           120           150           200           240 
##            16             2             1             1             1             1             1 
##           250           300           400           500           540          1000          1050 
##             1             4             2             2             1             4             1 
##          1500          1600          1800          2160          2400          2500          2760 
##             2             1             1             1             2             1             1 
##          2880          3000          3500          3750          4000          6000          7000 
##             1             1             1             1             1             1             1 
##          7200          8500          8982 10782 or more          <NA> 
##             1             1             1             1          2238

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q17_5)[na.exclude(mydata$s6q17_5)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q17_5", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q17_5. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##   50  140  150  200  750  776  900 2000 <NA> 
##    1    1    2    1    2    1    1    1 2286

## [1] "Frequency table after encoding"
## s6q17_5. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##           50          140          150          200          750          776          900 1950 or more 
##            1            1            2            1            2            1            1            1 
##         <NA> 
##         2286

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q19_5)[na.exclude(mydata$s6q19_5)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q19_5", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q19_5. What is the quantity of the crop harvested in the last 12 months? Please give th
##    0    1    4    5    6   10   20   30   33   35   40   50   60  100  450  500 1200 1500 <NA> 
##    8    2    1    3    2    3    2    1    1    1    2    1    1    1    1    1    1    1 2263

## [1] "Frequency table after encoding"
## s6q19_5. What is the quantity of the crop harvested in the last 12 months? Please give th
##            0            1            4            5            6           10           20           30 
##            8            2            1            3            2            3            2            1 
##           33           35           40           50           60          100          450          500 
##            1            1            2            1            1            1            1            1 
##         1200 1452 or more         <NA> 
##            1            1         2263

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q20_5)[na.exclude(mydata$s6q20_5)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q20_5", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q20_5. What is the total market value of the quantity harvested in the last 12 months? 
##     0    10    60    75    90   100   200   250   400   500   600   700   750   900  1200  1320  1400  1500 
##     8     1     1     1     1     1     1     1     1     1     1     1     1     1     1     1     1     2 
##  1750  1800  2500  5000 32400  <NA> 
##     1     2     1     1     1  2264

## [1] "Frequency table after encoding"
## s6q20_5. What is the total market value of the quantity harvested in the last 12 months? 
##             0            10            60            75            90           100           200 
##             8             1             1             1             1             1             1 
##           250           400           500           600           700           750           900 
##             1             1             1             1             1             1             1 
##          1200          1320          1400          1500          1750          1800          2500 
##             1             1             1             2             1             2             1 
##          5000 28152 or more          <NA> 
##             1             1          2264

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q21_5)[na.exclude(mydata$s6q21_5)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q21_5", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q21_5. What was the total revenue received from this crop harvest (sold in market trans
##     0    60    75   100   240   400   450   500   700   750  1000  1200  1260  1300  1500  1600  5000 32400 
##    12     1     1     1     1     2     1     1     2     2     1     1     1     1     1     1     1     1 
##  <NA> 
##  2264

## [1] "Frequency table after encoding"
## s6q21_5. What was the total revenue received from this crop harvest (sold in market trans
##             0            60            75           100           240           400           450 
##            12             1             1             1             1             2             1 
##           500           700           750          1000          1200          1260          1300 
##             1             2             2             1             1             1             1 
##          1500          1600          5000 28152 or more          <NA> 
##             1             1             1             1          2264

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q17_6)[na.exclude(mydata$s6q17_6)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q17_6", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q17_6. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##    0   50  776 2000 <NA> 
##    1    1    1    1 2292

## [1] "Frequency table after encoding"
## s6q17_6. How much was this start-up capital?  Magkano ang panimulang kapital na ito?
##            0           50          776 1981 or more         <NA> 
##            1            1            1            1         2292

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q19_6)[na.exclude(mydata$s6q19_6)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q19_6", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q19_6. What is the quantity of the crop harvested in the last 12 months? Please give th
##    0    2    7   15   30   40  100  500 <NA> 
##    2    1    1    1    1    2    1    1 2286

## [1] "Frequency table after encoding"
## s6q19_6. What is the quantity of the crop harvested in the last 12 months? Please give th
##           0           2           7          15          30          40         100 482 or more        <NA> 
##           2           1           1           1           1           2           1           1        2286

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q20_6)[na.exclude(mydata$s6q20_6)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q20_6", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q20_6. What is the total market value of the quantity harvested in the last 12 months? 
##     0    30   360   400  1600  4900  5000 25000  <NA> 
##     2     1     1     1     1     1     1     1  2287

## [1] "Frequency table after encoding"
## s6q20_6. What is the total market value of the quantity harvested in the last 12 months? 
##             0            30           360           400          1600          4900          5000 
##             2             1             1             1             1             1             1 
## 24200 or more          <NA> 
##             1          2287

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q21_6)[na.exclude(mydata$s6q21_6)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q21_6", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q21_6. What was the total revenue received from this crop harvest (sold in market trans
##     0   360   400  1600  3000  5000 13250 25000  <NA> 
##     2     1     1     1     1     1     1     1  2287

## [1] "Frequency table after encoding"
## s6q21_6. What was the total revenue received from this crop harvest (sold in market trans
##             0           360           400          1600          3000          5000         13250 
##             2             1             1             1             1             1             1 
## 24530 or more          <NA> 
##             1          2287

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q19_7)[na.exclude(mydata$s6q19_7)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q19_7", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q19_7. What is the quantity of the crop harvested in the last 12 months? Please give th
##    0  400 <NA> 
##    1    1 2294

## [1] "Frequency table after encoding"
## s6q19_7. What is the quantity of the crop harvested in the last 12 months? Please give th
##           0 398 or more        <NA> 
##           1           1        2294

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q20_7)[na.exclude(mydata$s6q20_7)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q20_7", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q20_7. What is the total market value of the quantity harvested in the last 12 months? 
##    0  400 <NA> 
##    1    1 2294

## [1] "Frequency table after encoding"
## s6q20_7. What is the total market value of the quantity harvested in the last 12 months? 
##           0 398 or more        <NA> 
##           1           1        2294

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q21_7)[na.exclude(mydata$s6q21_7)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q21_7", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q21_7. What was the total revenue received from this crop harvest (sold in market trans
##    0  400 <NA> 
##    1    1 2294

## [1] "Frequency table after encoding"
## s6q21_7. What was the total revenue received from this crop harvest (sold in market trans
##           0 398 or more        <NA> 
##           1           1        2294

mydata <- top_recode (variable="s6q22", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q22. In the last 12 months, how much in total did your household spend on Seeds ?  Sa
##      0      6     25     40     75    100    150    175    200    224    250    300    360    400    420 
##    240      1      1      3      1      3      2      1      2      1      3      5      1      3      2 
##    500    528    576    590    600    650    675    800    880    900    910   1000   1030   1050   1100 
##      7      1      1      1      2      1      1      2      1      3      1     12      1      2      1 
##   1200   1300   1400   1500   1550   1560   1600   1650   2000   2100   2400   2500   2550   2580   2600 
##      8      4      2      7      1      1      3      1     15      2      3      4      1      1      1 
##   2660   2700   2800   3000   3100   3300   3500   3600   3750   3900   4000   4050   4100   4500   4770 
##      1      2      2     14      1      2      3      2      1      1      5      1      1      3      1 
##   4800   4900   5000   5010   5200   5300   5500   5700   6000   6600   7000   7200   7500   7600   7700 
##      4      1     17      1      1      2      2      1      7      1      4      2      2      1      1 
##   8000   8300   8800   9000   9400  10000  11000  11500  12000  13500  13980  14000  15000  15300  15600 
##      6      1      2      1      1     15      5      1      5      1      1      1      4      1      1 
##  16000  16500  17500  17850  20000  21000  21400  21600  22600  25000  29400  29800  30000  33000  35000 
##      2      1      2      1      3      1      1      1      1      2      1      1      5      1      2 
##  45000  60000  60600  66000  76725  78500 208000   <NA> 
##      1      1      1      1      1      1      1   1771

## [1] "Frequency table after encoding"
## s6q22. In the last 12 months, how much in total did your household spend on Seeds ?  Sa
##           0           6          25          40          75         100         150         175         200 
##         240           1           1           3           1           3           2           1           2 
##         224         250         300         360 398 or more        <NA> 
##           1           3           5           1         261        1771

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q24)[na.exclude(mydata$s6q24)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q24", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q24. In the last 12 months, how much in total did your household spend on Fertilizers
##     0    47    50    90    93   100   120   140   150   160   180   200   250   280   300   325   330   350 
##   194     1     1     1     1     1     2     1     2     1     1     2     1     1     5     2     1     1 
##   432   435   450   500   600   620   700   730   800   890   900  1000  1040  1065  1085  1100  1150  1180 
##     1     1     2    11     5     1     1     1     1     1     1    18     1     1     1     1     1     1 
##  1200  1230  1350  1360  1400  1500  1530  1600  1700  1770  1780  1800  1900  1990  2000  2050  2150  2200 
##     6     1     1     1     2     8     1     1     2     1     1     3     2     1    14     3     1     6 
##  2220  2250  2270  2300  2310  2330  2340  2380  2400  2460  2500  2600  2700  2800  2840  2900  3000  3016 
##     1     1     1     1     1     1     1     1     1     1     7     2     1     2     1     1    13     1 
##  3150  3200  3280  3300  3400  3500  3620  3638  3680  3700  3800  4000  4100  4200  4500  4800  5000  5050 
##     1     1     1     1     1     4     1     1     1     1     1     9     1     3     2     1    10     1 
##  5400  5418  5500  5600  5760  5880  6000  6250  6300  6500  6506  6600  6720  6790  7000  7100  7150  7170 
##     1     1     1     1     1     1     8     1     1     1     1     2     1     1     8     1     1     1 
##  7200  7700  8000  8400  8800  9400  9500  9600 10000 10650 11000 11350 11900 12000 12360 12600 12800 13000 
##     1     1     8     3     2     1     1     1    16     1     1     1     1     9     1     1     1     1 
## 14000 14500 14730 15000 15200 15600 16000 17000 17100 18000 18600 20000 20140 21000 21200 22200 23350 23800 
##     3     1     1     1     1     1     1     1     1     3     1     4     1     2     1     1     1     1 
## 24200 25000 25600 29400 30000 36000 50000 55860 60000 66000 76000  <NA> 
##     1     1     1     1     2     1     1     1     1     1     1  1771

## [1] "Frequency table after encoding"
## s6q24. In the last 12 months, how much in total did your household spend on Fertilizers
##             0            47            50            90            93           100           120 
##           194             1             1             1             1             1             2 
##           140           150           160           180           200           250           280 
##             1             2             1             1             2             1             1 
##           300           325           330           350           432           435           450 
##             5             2             1             1             1             1             2 
##           500           600           620           700           730           800           890 
##            11             5             1             1             1             1             1 
##           900          1000          1040          1065          1085          1100          1150 
##             1            18             1             1             1             1             1 
##          1180          1200          1230          1350          1360          1400          1500 
##             1             6             1             1             1             2             8 
##          1530          1600          1700          1770          1780          1800          1900 
##             1             1             2             1             1             3             2 
##          1990          2000          2050          2150          2200          2220          2250 
##             1            14             3             1             6             1             1 
##          2270          2300          2310          2330          2340          2380          2400 
##             1             1             1             1             1             1             1 
##          2460          2500          2600          2700          2800          2840          2900 
##             1             7             2             1             2             1             1 
##          3000          3016          3150          3200          3280          3300          3400 
##            13             1             1             1             1             1             1 
##          3500          3620          3638          3680          3700          3800          4000 
##             4             1             1             1             1             1             9 
##          4100          4200          4500          4800          5000          5050          5400 
##             1             3             2             1            10             1             1 
##          5418          5500          5600          5760          5880          6000          6250 
##             1             1             1             1             1             8             1 
##          6300          6500          6506          6600          6720          6790          7000 
##             1             1             1             2             1             1             8 
##          7100          7150          7170          7200          7700          8000          8400 
##             1             1             1             1             1             8             3 
##          8800          9400          9500          9600         10000         10650         11000 
##             2             1             1             1            16             1             1 
##         11350         11900         12000         12360         12600         12800         13000 
##             1             1             9             1             1             1             1 
##         14000         14500         14730         15000         15200         15600         16000 
##             3             1             1             1             1             1             1 
##         17000         17100         18000         18600         20000         20140         21000 
##             1             1             3             1             4             1             2 
##         21200         22200         23350         23800         24200         25000         25600 
##             1             1             1             1             1             1             1 
##         29400         30000         36000         50000         55860 57433 or more          <NA> 
##             1             2             1             1             1             3          1771

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q26)[na.exclude(mydata$s6q26)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q26", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q26. In the last 12 months, how much in total did your household spend on Hire machin
##     0    25   130   150   160   220   300   308   350   400   500   600   700   715   800   805   880   900 
##   340     1     1     1     1     1     3     1     1     2     7     9     3     1     5     1     1     2 
##  1000  1100  1200  1300  1400  1450  1500  1600  1800  1920  2000  2178  2200  2250  2380  2400  2500  2600 
##    13     1     8     3     4     1    12     5     2     1    21     1     1     1     1     5     5     1 
##  2700  2736  2800  2870  2975  3000  3200  3250  3420  3600  3700  4000  4200  4500  5000  5100  5250  5600 
##     1     1     3     1     1     6     1     1     1     2     1     7     2     4     5     1     1     1 
##  5700  6000  7000  8000  8700  8960  9000  9500  9800 10000 10735 16000 16800 19000 30000  <NA> 
##     1     3     3     1     1     1     2     1     1     1     1     1     1     1     1  1769

## [1] "Frequency table after encoding"
## s6q26. In the last 12 months, how much in total did your household spend on Hire machin
##             0            25           130           150           160           220           300 
##           340             1             1             1             1             1             3 
##           308           350           400           500           600           700           715 
##             1             1             2             7             9             3             1 
##           800           805           880           900          1000          1100          1200 
##             5             1             1             2            13             1             8 
##          1300          1400          1450          1500          1600          1800          1920 
##             3             4             1            12             5             2             1 
##          2000          2178          2200          2250          2380          2400          2500 
##            21             1             1             1             1             5             5 
##          2600          2700          2736          2800          2870          2975          3000 
##             1             1             1             3             1             1             6 
##          3200          3250          3420          3600          3700          4000          4200 
##             1             1             1             2             1             7             2 
##          4500          5000          5100          5250          5600          5700          6000 
##             4             5             1             1             1             1             3 
##          7000          8000          8700          8960          9000          9500          9800 
##             3             1             1             1             2             1             1 
##         10000         10735         16000 16296 or more          <NA> 
##             1             1             1             3          1769

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q28)[na.exclude(mydata$s6q28)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q28", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q28. In the last 12 months, how much in total did your household spend on Water (incl
##     0    15    20    96   200   216   260   300   400   480   500   600   700   800   840   900   934  1000 
##   451     1     1     1     1     1     1     5     1     1    11     4     1     3     1     2     1     7 
##  1100  1188  1200  1500  1550  1568  1600  1800  2000  2200  2400  3000  3200  4000  4342  5000  7000  7665 
##     2     1     2     1     1     1     2     1     4     1     1     4     1     3     1     2     1     1 
##  8000  9000 10000 12000  <NA> 
##     2     1     4     1  1764

## [1] "Frequency table after encoding"
## s6q28. In the last 12 months, how much in total did your household spend on Water (incl
##             0            15            20            96           200           216           260 
##           451             1             1             1             1             1             1 
##           300           400           480           500           600           700           800 
##             5             1             1            11             4             1             3 
##           840           900           934          1000          1100          1188          1200 
##             1             2             1             7             2             1             2 
##          1500          1550          1568          1600          1800          2000          2200 
##             1             1             1             2             1             4             1 
##          2400          3000          3200          4000          4342          5000          7000 
##             1             4             1             3             1             2             1 
##          7665          8000          9000 10000 or more          <NA> 
##             1             2             1             5          1764

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q30)[na.exclude(mydata$s6q30)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q30", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q30. In the last 12 months, how much in total did your household spend on Hiring Labo
##     0     1    17   300   400   450   500   600   700   800   900  1000  1150  1200  1275  1352  1360  1500 
##   292     1     1     5     2     7     6     9     1     9     4    14     1     4     1     1     2     3 
##  1600  1800  1900  2000  2100  2200  2400  2500  3000  3200  3400  3500  3750  3980  4000  4450  4500  4800 
##     4     2     3    16     2     3     7     3    25     2     2     2     1     1    15     1     6     2 
##  5000  5100  5200  5250  5460  5600  6000  6100  7000  7200  7500  7933  8000  9000  9600 10000 10500 10800 
##     9     1     1     1     1     1     9     1     2     1     1     1     6     2     1     6     1     1 
## 11500 11840 12000 13000 13500 14000 15000 16000 16200 20000 21900 22000 24000 35000 38400 40000 47000  <NA> 
##     1     1     4     1     1     1     3     1     1     1     1     1     1     1     1     1     1  1768

## [1] "Frequency table after encoding"
## s6q30. In the last 12 months, how much in total did your household spend on Hiring Labo
##             0             1            17           300           400           450           500 
##           292             1             1             5             2             7             6 
##           600           700           800           900          1000          1150          1200 
##             9             1             9             4            14             1             4 
##          1275          1352          1360          1500          1600          1800          1900 
##             1             1             2             3             4             2             3 
##          2000          2100          2200          2400          2500          3000          3200 
##            16             2             3             7             3            25             2 
##          3400          3500          3750          3980          4000          4450          4500 
##             2             2             1             1            15             1             6 
##          4800          5000          5100          5200          5250          5460          5600 
##             2             9             1             1             1             1             1 
##          6000          6100          7000          7200          7500          7933          8000 
##             9             1             2             1             1             1             6 
##          9000          9600         10000         10500         10800         11500         11840 
##             2             1             6             1             1             1             1 
##         12000         13000         13500         14000         15000         16000         16200 
##             4             1             1             1             3             1             1 
##         20000         21900         22000         24000         35000 36241 or more          <NA> 
##             1             1             1             1             1             3          1768

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q32)[na.exclude(mydata$s6q32)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q32", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q32. In the last 12 months, how much in total did your household spend on Other expen
##     0    40    50    60    75    80   100   128   150   200   264   271   300   400   500   600   665   800 
##   433     1     1     1     1     1     4     1     2     4     1     1     6     1     6     4     1     2 
##  1000  1008  1120  1200  1400  1500  1680  1800  2000  2050  2500  2800  3000  3190  4000  4200  4250  4500 
##    11     1     1     1     1     5     1     2     6     1     1     2     3     1     2     1     1     1 
##  4856  5000  5040  6000  6720  7000  9600 10000 11100 12000 15000 16800 45500 48000  <NA> 
##     1     3     1     1     1     1     1     1     1     1     1     1     1     1  1767

## [1] "Frequency table after encoding"
## s6q32. In the last 12 months, how much in total did your household spend on Other expen
##             0            40            50            60            75            80           100 
##           433             1             1             1             1             1             4 
##           128           150           200           264           271           300           400 
##             1             2             4             1             1             6             1 
##           500           600           665           800          1000          1008          1120 
##             6             4             1             2            11             1             1 
##          1200          1400          1500          1680          1800          2000          2050 
##             1             1             5             1             2             6             1 
##          2500          2800          3000          3190          4000          4200          4250 
##             1             2             3             1             2             1             1 
##          4500          4856          5000          5040          6000          6720          7000 
##             1             1             3             1             1             1             1 
##          9600         10000         11100         12000         15000 15648 or more          <NA> 
##             1             1             1             1             1             3          1767

percentile_99.5 <- floor(quantile(na.exclude(mydata$s6q35)[na.exclude(mydata$s6q35)!=999999], probs = c(0.995)))
mydata <- top_recode (variable="s6q35", break_point=percentile_99.5, missing=999999)
## [1] "Frequency table before encoding"
## s6q35. What are your household's total profits from farming in the last 12 months?   Ma
##      0    100    140    150    200    270    300    350    360    400    417    475    480    500    585 
##    146      1      1      3      2      1      1      1      1      1      1      1      1      2      1 
##    600    636    640    650    700    710    750    800    840    890    945   1000   1111   1475   1500 
##      1      1      1      1      1      1      1      1      1      1      1      9      1      1      4 
##   1530   1600   1700   1720   1750   1760   1800   1960   2000   2100   2200   2250   2340   2400   2415 
##      1      1      1      1      1      1      5      1      8      1      1      1      1      2      1 
##   2500   2528   2560   2590   2640   2784   2900   2965   2990   3000   3100   3104   3120   3150   3350 
##      2      1      1      1      1      1      2      1      2      6      1      1      2      1      1 
##   3395   3400   3500   3680   3700   3750   4000   4080   4186   4300   4305   4500   4700   4750   4760 
##      1      1      2      1      1      1      8      1      1      1      1      1      1      1      1 
##   5000   5103   5500   5600   5626   5680   6000   6100   6464   6500   6550   6590   6600   6760   6800 
##     17      1      1      1      1      1     10      1      1      1      1      1      1      1      1 
##   6930   6978   7000   7050   7060   7185   7200   7500   7560   7570   7650   7866   7971   8000   8150 
##      1      1      3      1      1      1      1      2      1      1      1      1      1      6      1 
##   8160   8200   8208   8500   8620   8650   8740   8760   9000   9180   9288   9500   9700   9750  10000 
##      1      1      1      2      1      1      1      1      3      1      1      1      1      1     11 
##  10600  10640  10920  11030  11657  11905  11968  12000  12350  12550  12630  12680  12900  13500  13680 
##      1      1      1      1      1      1      1      6      1      1      1      1      1      1      1 
##  13704  13720  14300  14552  14776  14900  15000  15520  16000  16082  16300  16800  17250  17984  18000 
##      1      1      1      1      1      1      4      1      2      1      1      1      1      1      3 
##  18800  18950  19000  19200  19300  19800  19940  20000  20225  21000  21400  21600  22000  22200  22350 
##      1      1      3      1      1      2      1      8      1      4      1      1      1      1      1 
##  22500  22660  22890  23000  23475  23700  24000  24500  25000  25500  26100  26400  27184  28500  28840 
##      2      1      1      1      1      1      1      1      3      1      1      1      1      1      1 
##  29000  29124  29800  30000  31200  31280  31500  32000  32200  32730  33000  33600  34000  35000  35360 
##      1      1      2      7      1      1      1      1      1      1      1      1      1      1      1 
##  35900  36008  36069  37400  39304  40000  40400  40500  44352  48130  55000  55800  59610  59620  60000 
##      1      1      1      1      1      4      1      1      1      1      1      1      1      1      3 
##  63000  68000  76500  76568  85640  96000 105000 108000 148000 190000 359100 448280   <NA> 
##      1      1      1      1      1      1      1      1      1      1      1      1   1800

## [1] "Frequency table after encoding"
## s6q35. What are your household's total profits from farming in the last 12 months?   Ma
##              0            100            140            150            200            270            300 
##            146              1              1              3              2              1              1 
##            350            360            400            417            475            480            500 
##              1              1              1              1              1              1              2 
##            585            600            636            640            650            700            710 
##              1              1              1              1              1              1              1 
##            750            800            840            890            945           1000           1111 
##              1              1              1              1              1              9              1 
##           1475           1500           1530           1600           1700           1720           1750 
##              1              4              1              1              1              1              1 
##           1760           1800           1960           2000           2100           2200           2250 
##              1              5              1              8              1              1              1 
##           2340           2400           2415           2500           2528           2560           2590 
##              1              2              1              2              1              1              1 
##           2640           2784           2900           2965           2990           3000           3100 
##              1              1              2              1              2              6              1 
##           3104           3120           3150           3350           3395           3400           3500 
##              1              2              1              1              1              1              2 
##           3680           3700           3750           4000           4080           4186           4300 
##              1              1              1              8              1              1              1 
##           4305           4500           4700           4750           4760           5000           5103 
##              1              1              1              1              1             17              1 
##           5500           5600           5626           5680           6000           6100           6464 
##              1              1              1              1             10              1              1 
##           6500           6550           6590           6600           6760           6800           6930 
##              1              1              1              1              1              1              1 
##           6978           7000           7050           7060           7185           7200           7500 
##              1              3              1              1              1              1              2 
##           7560           7570           7650           7866           7971           8000           8150 
##              1              1              1              1              1              6              1 
##           8160           8200           8208           8500           8620           8650           8740 
##              1              1              1              2              1              1              1 
##           8760           9000           9180           9288           9500           9700           9750 
##              1              3              1              1              1              1              1 
##          10000          10600          10640          10920          11030          11657          11905 
##             11              1              1              1              1              1              1 
##          11968          12000          12350          12550          12630          12680          12900 
##              1              6              1              1              1              1              1 
##          13500          13680          13704          13720          14300          14552          14776 
##              1              1              1              1              1              1              1 
##          14900          15000          15520          16000          16082          16300          16800 
##              1              4              1              2              1              1              1 
##          17250          17984          18000          18800          18950          19000          19200 
##              1              1              3              1              1              3              1 
##          19300          19800          19940          20000          20225          21000          21400 
##              1              2              1              8              1              4              1 
##          21600          22000          22200          22350          22500          22660          22890 
##              1              1              1              1              2              1              1 
##          23000          23475          23700          24000          24500          25000          25500 
##              1              1              1              1              1              3              1 
##          26100          26400          27184          28500          28840          29000          29124 
##              1              1              1              1              1              1              1 
##          29800          30000          31200          31280          31500          32000          32200 
##              2              7              1              1              1              1              1 
##          32730          33000          33600          34000          35000          35360          35900 
##              1              1              1              1              1              1              1 
##          36008          36069          37400          39304          40000          40400          40500 
##              1              1              1              1              4              1              1 
##          44352          48130          55000          55800          59610          59620          60000 
##              1              1              1              1              1              1              3 
##          63000          68000          76500          76568          85640          96000         105000 
##              1              1              1              1              1              1              1 
##         108000         148000 170049 or more           <NA> 
##              1              1              3           1800

Indirect PII - Categorical: Recode, encode, or Top/bottom coding for extreme values

# !!!Include relevant variables in list below (Indirect PII - Categorical, and Ordinal if not processed yet)

indirect_PII <- c("s6q1",
                  "s6q2unit",
                  "s6q2a",
                  "s6q3",
                  "s6q4",
                  "s6q5",
                  "s6q6",
                  "s6q8",
                  "s6q10",
                  "s6qn16",
                  "s6q12",
                  "s6q13_1",
                  "s6q15_1",
                  "s6q16_1",
                  "s6q18_1",
                  "s6q13_2",
                  "s6q15_2",
                  "s6q16_2",
                  "s6q18_2",
                  "s6q13_3",
                  "s6q15_3",
                  "s6q16_3",
                  "s6q18_3",
                  "s6q13_4",
                  "s6q15_4",
                  "s6q16_4",
                  "s6q18_4",
                  "s6q13_5",
                  "s6q15_5",
                  "s6q16_5",
                  "s6q18_5",
                  "s6q13_6",
                  "s6q15_6",
                  "s6q16_6",
                  "s6q18_6",
                  "s6q13_7",
                  "s6q15_7",
                  "s6q18_7",
                  "s6q13_8",
                  "s6q15_8",
                  "s6q16_8",
                  "s6q18_8",
                  "s6q13_9",
                  "s6q15_9",
                  "s6q16_9",
                  "s6q18_9",
                  "s6q13_10",
                  "s6q15_10",
                  "s6q16_10",
                  "s6q18_10",
                  "s6q13_11",
                  "s6q15_11",
                  "s6q18_11",
                  "s6q15_12",
                  "s6q18_12",
                  "s6q13_13",
                  "s6q15_13",
                  "s6q16_13",
                  "s6q18_13",
                  "s6q13_14",
                  "s6q15_14",
                  "s6q16_14",
                  "s6q18_14",
                  "s6q13_15",
                  "s6q15_15",
                  "s6q16_15",
                  "s6q18_15",
                  "s6q13_16",
                  "s6q15_16",
                  "s6q16_16",
                  "s6q18_16",
                  "s6q13_17",
                  "s6q15_17",
                  "s6q16_17",
                  "s6q18_17",
                  "s6q15_18",
                  "s6q18_18",
                  "s6q15_19",
                  "s6q16_19",
                  "s6q18_19",
                  "s6q15_20",
                  "s6q16_20",
                  "s6q18_20",
                  "s6q15_21",
                  "s6q16_21",
                  "s6q18_21",
                  "s6q13_22",
                  "s6q15_22",
                  "s6q18_22",
                  "s6q15_23",
                  "s6q16_23",
                  "s6q18_23")

capture_tables (indirect_PII)



# Recode those with very specific values. 

break_units <- c(-999,1,2,3)
labels_units <- c("No Response"=1,
                "Hectares" = 2,
                "Square Meters" = 3,
                "Other"=4)
mydata <- ordinal_recode (variable="s6q2unit", break_points=break_units, missing=999999, value_labels=labels_units)

## [1] "Frequency table before encoding"
## s6q2unit. What unit is the land measured in?  Anong yunit sinukat ang lupa?
##      Hectares Square Meters        Tupong          <NA> 
##            54           332             2          1908 
##    recoded
##     [-999,1) [1,2) [2,3) [3,1e+06)
##   1        0    54     0         0
##   2        0     0   332         0
##   3        0     0     0         2
## [1] "Frequency table after encoding"
## s6q2unit. What unit is the land measured in?  Anong yunit sinukat ang lupa?
##      Hectares Square Meters         Other          <NA> 
##            54           332             2          1908 
## [1] "Inspect value labels and relabel as necessary"
##   No Response      Hectares Square Meters         Other 
##             1             2             3             4
mydata <- ordinal_recode (variable="s6q4", break_points=break_units, missing=999999, value_labels=labels_units)

## [1] "Frequency table before encoding"
## s6q4. What unit is the land measured in?  Anong yunit sinukat ang lupa?
##      Hectares Square Meters        Tupong          <NA> 
##            91            90             7          2108 
##    recoded
##     [-999,1) [1,2) [2,3) [3,1e+06)
##   1        0    91     0         0
##   2        0     0    90         0
##   3        0     0     0         7
## [1] "Frequency table after encoding"
## s6q4. What unit is the land measured in?  Anong yunit sinukat ang lupa?
##      Hectares Square Meters         Other          <NA> 
##            91            90             7          2108 
## [1] "Inspect value labels and relabel as necessary"
##   No Response      Hectares Square Meters         Other 
##             1             2             3             4
break_owner <- c(-999,-888,1,2,3)
labels_owner <- c("No Response"=1,
                  "Other (specify)" = 2,
                  "Husband or husband's family" = 3,
                  "Wife or wife's family"=4,
                  "Other"=5)
mydata <- ordinal_recode (variable="s6q5", break_points=break_owner, missing=999999, value_labels=labels_owner)

## [1] "Frequency table before encoding"
## s6q5. Who owns this land?   Sino ang may-ari ng lupang ito?
##      Husband or husband's family            Wife or wife's family Shared ownership between 1 and 2 
##                              111                               40                               29 
##                             <NA> 
##                             2116 
##    recoded
##     [-999,-888) [-888,1) [1,2) [2,3) [3,1e+06)
##   1           0        0   111     0         0
##   2           0        0     0    40         0
##   3           0        0     0     0        29
## [1] "Frequency table after encoding"
## s6q5. Who owns this land?   Sino ang may-ari ng lupang ito?
## Husband or husband's family       Wife or wife's family                       Other 
##                         111                          40                          29 
##                        <NA> 
##                        2116 
## [1] "Inspect value labels and relabel as necessary"
##                 No Response             Other (specify) Husband or husband's family 
##                           1                           2                           3 
##       Wife or wife's family                       Other 
##                           4                           5
break_crop <- c(-999,-888,1,2,3,4)
labels_crop <- c("No Response"=1,
                  "Other (specify)" = 2,
                  "Rice" = 3,
                  "Corn"=4,
                  "Coconut"=5,
                  "Other"=6)
mydata <- ordinal_recode (variable="s6q13_1", break_points=break_crop, missing=999999, value_labels=labels_crop)

## [1] "Frequency table before encoding"
## s6q13_1. What crop did your household cultivate in the last 12 months?   Anong panahim an
##            Rice            Corn         Coconut           Abaca    Baguio beans    Sweet potato 
##             203             113              44              10               3              12 
##         Cassava   Water spinach          Coffee       Jackfruit          Ginger Mango (Carabao) 
##              35               1               1               2               3               2 
##  Mango (Indian)          Peanut            Okra      Watermelon          Pepper          Papaya 
##               1               2               1               1               1               1 
##       Pineapple        Rambutan          Banana           Onion           Chili    String beans 
##               3               1              31               1               1               7 
##         Tobacco        Eggplant       Sugarcane            <NA> 
##               2               5              14            1795 
##     recoded
##      [-999,-888) [-888,1) [1,2) [2,3) [3,4) [4,1e+06)
##   1            0        0   203     0     0         0
##   2            0        0     0   113     0         0
##   3            0        0     0     0    44         0
##   4            0        0     0     0     0        10
##   5            0        0     0     0     0         3
##   11           0        0     0     0     0        12
##   12           0        0     0     0     0        35
##   13           0        0     0     0     0         1
##   14           0        0     0     0     0         1
##   15           0        0     0     0     0         2
##   17           0        0     0     0     0         3
##   18           0        0     0     0     0         2
##   19           0        0     0     0     0         1
##   21           0        0     0     0     0         2
##   22           0        0     0     0     0         1
##   23           0        0     0     0     0         1
##   24           0        0     0     0     0         1
##   25           0        0     0     0     0         1
##   26           0        0     0     0     0         3
##   28           0        0     0     0     0         1
##   30           0        0     0     0     0        31
##   31           0        0     0     0     0         1
##   32           0        0     0     0     0         1
##   34           0        0     0     0     0         7
##   35           0        0     0     0     0         2
##   36           0        0     0     0     0         5
##   37           0        0     0     0     0        14
## [1] "Frequency table after encoding"
## s6q13_1. What crop did your household cultivate in the last 12 months?   Anong panahim an
##    Rice    Corn Coconut   Other    <NA> 
##     203     113      44     141    1795 
## [1] "Inspect value labels and relabel as necessary"
##     No Response Other (specify)            Rice            Corn         Coconut           Other 
##               1               2               3               4               5               6
break_crop <- c(-999,-888,1,2,3)
labels_crop <- c("No Response"=1,
                 "Other (specify)" = 2,
                 "Rice" = 3,
                 "Corn"=4,
                 "Other"=5)
mydata <- ordinal_recode (variable="s6q13_2", break_points=break_crop, missing=999999, value_labels=labels_crop)

## [1] "Frequency table before encoding"
## s6q13_2. What crop did your household cultivate in the last 12 months?   Anong panahim an
##            Rice            Corn         Coconut           Abaca    Baguio beans       Calamansi 
##              24              38              16              10               2               1 
##           Cacao          Tomato    Sweet potato         Cassava        Lanzones          Ginger 
##               1               1              22              26               1               3 
## Mango (Carabao)  Mango (Indian)          Peanut      Watermelon          Pepper          Papaya 
##               2               1               5               3               1               1 
##       Pineapple          Banana           Chili    String beans        Eggplant       Sugarcane 
##               2              20               2               7               5               1 
##          Squash            <NA> 
##               3            2098 
##     recoded
##      [-999,-888) [-888,1) [1,2) [2,3) [3,1e+06)
##   1            0        0    24     0         0
##   2            0        0     0    38         0
##   3            0        0     0     0        16
##   4            0        0     0     0        10
##   5            0        0     0     0         2
##   7            0        0     0     0         1
##   8            0        0     0     0         1
##   10           0        0     0     0         1
##   11           0        0     0     0        22
##   12           0        0     0     0        26
##   16           0        0     0     0         1
##   17           0        0     0     0         3
##   18           0        0     0     0         2
##   19           0        0     0     0         1
##   21           0        0     0     0         5
##   23           0        0     0     0         3
##   24           0        0     0     0         1
##   25           0        0     0     0         1
##   26           0        0     0     0         2
##   30           0        0     0     0        20
##   32           0        0     0     0         2
##   34           0        0     0     0         7
##   36           0        0     0     0         5
##   37           0        0     0     0         1
##   38           0        0     0     0         3
## [1] "Frequency table after encoding"
## s6q13_2. What crop did your household cultivate in the last 12 months?   Anong panahim an
##  Rice  Corn Other  <NA> 
##    24    38   136  2098 
## [1] "Inspect value labels and relabel as necessary"
##     No Response Other (specify)            Rice            Corn           Other 
##               1               2               3               4               5
break_source <- c(-999,-888,1,2,4,5)
labels_source <- c("No Response"=1,
                 "Other (specify)" = 2,
                 "Loan from family and friends" = 3,
                 "Other"=4,
                 "Personal savings"=5,
                 "Other"=6)
mydata <- ordinal_recode (variable="s6q16_1", break_points=break_source, missing=999999, value_labels=labels_source)

## [1] "Frequency table before encoding"
## s6q16_1. What was the main source of start-up capital (such as money or goods) for this c
##              1. Loan from family and friends              2. Gift from family and friends 
##                                           91                                            4 
##                            3. Sale of assets                          4. Personal savings 
##                                            7                                          122 
##           5. Regular or micro-loan from bank                    6. Loan from money-lender 
##                                           10                                           28 
##            7. NGO or charitable organization 8. Reinvested profit from another enterprise 
##                                            3                                           11 
##      9. Rosca/Self-help group/merry-go-round              10. Government Transfer Program 
##                                            1                                            1 
##                                         <NA> 
##                                         2018 
##     recoded
##      [-999,-888) [-888,1) [1,2) [2,4) [4,5) [5,1e+06)
##   1            0        0    91     0     0         0
##   2            0        0     0     4     0         0
##   3            0        0     0     7     0         0
##   4            0        0     0     0   122         0
##   5            0        0     0     0     0        10
##   6            0        0     0     0     0        28
##   7            0        0     0     0     0         3
##   8            0        0     0     0     0        11
##   9            0        0     0     0     0         1
##   10           0        0     0     0     0         1
## [1] "Frequency table after encoding"
## s6q16_1. What was the main source of start-up capital (such as money or goods) for this c
## Loan from family and friends                        Other             Personal savings 
##                           91                           65                          122 
##                         <NA> 
##                         2018 
## [1] "Inspect value labels and relabel as necessary"
##                  No Response              Other (specify) Loan from family and friends 
##                            1                            2                            3 
##                        Other             Personal savings                        Other 
##                            4                            5                            6
break_source <- c(-999,-888,1,2,4,5)
labels_source <- c("No Response"=1,
                   "Other (specify)" = 2,
                   "Other" = 3,
                   "Other"=4,
                   "Personal savings"=5,
                   "Other"=6)
mydata <- ordinal_recode (variable="s6q16_2", break_points=break_source, missing=999999, value_labels=labels_source)

## [1] "Frequency table before encoding"
## s6q16_2. What was the main source of start-up capital (such as money or goods) for this c
##              1. Loan from family and friends              2. Gift from family and friends 
##                                           19                                            2 
##                            3. Sale of assets                          4. Personal savings 
##                                            2                                           50 
##                    6. Loan from money-lender 8. Reinvested profit from another enterprise 
##                                           13                                            9 
##                                         <NA> 
##                                         2201 
##    recoded
##     [-999,-888) [-888,1) [1,2) [2,4) [4,5) [5,1e+06)
##   1           0        0    19     0     0         0
##   2           0        0     0     2     0         0
##   3           0        0     0     2     0         0
##   4           0        0     0     0    50         0
##   6           0        0     0     0     0        13
##   8           0        0     0     0     0         9
## [1] "Frequency table after encoding"
## s6q16_2. What was the main source of start-up capital (such as money or goods) for this c
##            Other Personal savings             <NA> 
##               45               50             2201 
## [1] "Inspect value labels and relabel as necessary"
##      No Response  Other (specify)            Other            Other Personal savings            Other 
##                1                2                3                4                5                6
break_measure <- c(-999,-888,1,2,3)
labels_measure <- c("No Response"=1,
                   "Other (specify)" = 2,
                   "Kilograms" = 3,
                   "Sacks"=4,
                   "Other"=5)
mydata <- ordinal_recode (variable="s6q18_1", break_points=break_measure, missing=999999, value_labels=labels_measure)

## [1] "Frequency table before encoding"
## s6q18_1. How is crop quantity measured?  Paano sinusukat ang bilang ng mga ani?
## Kilograms     Sacks    Pieces       Can   Bundles      Tons   Bunches      <NA> 
##       143       295        40         6        24         4         7      1777 
##     recoded
##      [-999,-888) [-888,1) [1,2) [2,3) [3,1e+06)
##   1            0        0   143     0         0
##   2            0        0     0   295         0
##   3            0        0     0     0        40
##   4            0        0     0     0         6
##   7            0        0     0     0        24
##   9            0        0     0     0         4
##   15           0        0     0     0         7
## [1] "Frequency table after encoding"
## s6q18_1. How is crop quantity measured?  Paano sinusukat ang bilang ng mga ani?
## Kilograms     Sacks     Other      <NA> 
##       143       295        81      1777 
## [1] "Inspect value labels and relabel as necessary"
##     No Response Other (specify)       Kilograms           Sacks           Other 
##               1               2               3               4               5
mydata <- ordinal_recode (variable="s6q18_2", break_points=break_measure, missing=999999, value_labels=labels_measure)

## [1] "Frequency table before encoding"
## s6q18_2. How is crop quantity measured?  Paano sinusukat ang bilang ng mga ani?
## Kilograms     Sacks    Pieces       Can   Bundles      Tons   Bunches      Bags      <NA> 
##        88        76        29        10         7         1         6         1      2078 
##     recoded
##      [-999,-888) [-888,1) [1,2) [2,3) [3,1e+06)
##   1            0        0    88     0         0
##   2            0        0     0    76         0
##   3            0        0     0     0        29
##   4            0        0     0     0        10
##   7            0        0     0     0         7
##   9            0        0     0     0         1
##   15           0        0     0     0         6
##   16           0        0     0     0         1
## [1] "Frequency table after encoding"
## s6q18_2. How is crop quantity measured?  Paano sinusukat ang bilang ng mga ani?
## Kilograms     Sacks     Other      <NA> 
##        88        76        54      2078 
## [1] "Inspect value labels and relabel as necessary"
##     No Response Other (specify)       Kilograms           Sacks           Other 
##               1               2               3               4               5
break_measure <- c(-999,-888,1,2)
labels_measure <- c("No Response"=1,
                    "Other (specify)" = 2,
                    "Kilograms" = 3,
                    "Other"=4)
mydata <- ordinal_recode (variable="s6q18_3", break_points=break_measure, missing=999999, value_labels=labels_measure)

## [1] "Frequency table before encoding"
## s6q18_3. How is crop quantity measured?  Paano sinusukat ang bilang ng mga ani?
## Kilograms     Sacks    Pieces       Can   Bundles   Bunches      Bags      <NA> 
##        52         6        14         7        10         6         1      2200 
##     recoded
##      [-999,-888) [-888,1) [1,2) [2,1e+06)
##   1            0        0    52         0
##   2            0        0     0         6
##   3            0        0     0        14
##   4            0        0     0         7
##   7            0        0     0        10
##   15           0        0     0         6
##   16           0        0     0         1
## [1] "Frequency table after encoding"
## s6q18_3. How is crop quantity measured?  Paano sinusukat ang bilang ng mga ani?
## Kilograms     Other      <NA> 
##        52        44      2200 
## [1] "Inspect value labels and relabel as necessary"
##     No Response Other (specify)       Kilograms           Other 
##               1               2               3               4
mydata <- ordinal_recode (variable="s6q18_4", break_points=break_measure, missing=999999, value_labels=labels_measure)

## [1] "Frequency table before encoding"
## s6q18_4. How is crop quantity measured?  Paano sinusukat ang bilang ng mga ani?
## Kilograms     Sacks    Pieces       Can   Bundles   Bunches      <NA> 
##        33         5         8         2         5         3      2240 
##     recoded
##      [-999,-888) [-888,1) [1,2) [2,1e+06)
##   1            0        0    33         0
##   2            0        0     0         5
##   3            0        0     0         8
##   4            0        0     0         2
##   7            0        0     0         5
##   15           0        0     0         3
## [1] "Frequency table after encoding"
## s6q18_4. How is crop quantity measured?  Paano sinusukat ang bilang ng mga ani?
## Kilograms     Other      <NA> 
##        33        23      2240 
## [1] "Inspect value labels and relabel as necessary"
##     No Response Other (specify)       Kilograms           Other 
##               1               2               3               4

Matching and crosstabulations: Run automated PII check

# !!! Insufficient demographic data

Open-ends: review responses for any sensitive information, redact as necessary

# !!! Identify open-end variables here: 
open_ends <- c("s6q1whynoresponse",
               "s6q2unitwhynoresponse",
               "s6q2whynoresponse",
               "s6q2awhynoresponse",
               "s6q3whynoresponse",
               "s6q4whynoresponse",
               "s6q4awhynoresponse",
               "s6q5_other",
               "s6q5whynoresponse",
               "s6q6whynoresponse",
               "s6q7whynoresponse",
               "s6q8whynoresponse",
               "s6q9whynoresponse",
               "s6q9awhynoresponse",
               "s6q10whynoresponse",
               "s6q11whynoresponse",
               "s6qn16whynoresponse",
               "s6q12whynoresponse",
               "s6q12countwhynoresponse",
               "s6q14_1",
               "s6q15awhynoresponse_1",
               "s6q15whynoresponse_1",
               "s6q16other_1",
               "s6q16whynoresponse_1",
               "s6q17whynoresponse_1",
               "s6q19whynoresponse_1",
               "s6q18other_1",
               "s6q18whynoresponse_1",
               "s6q19awhynoresponse_1",
               "s6q20whynoresponse_1",
               "s6q21whynoresponse_1",
               "s6q14_2",
               "s6q15awhynoresponse_2",
               "s6q15whynoresponse_2",
               "s6q16other_2",
               "s6q16whynoresponse_2",
               "s6q17whynoresponse_2",
               "s6q19whynoresponse_2",
               "s6q18other_2",
               "s6q18whynoresponse_2",
               "s6q19awhynoresponse_2",
               "s6q20whynoresponse_2",
               "s6q21whynoresponse_2",
               "s6q14_3",
               "s6q15awhynoresponse_3",
               "s6q15whynoresponse_3",
               "s6q16other_3",
               "s6q16whynoresponse_3",
               "s6q17whynoresponse_3",
               "s6q19whynoresponse_3",
               "s6q18other_3",
               "s6q18whynoresponse_3",
               "s6q19awhynoresponse_3",
               "s6q20whynoresponse_3",
               "s6q21whynoresponse_3",
               "s6q14_4",
               "s6q15awhynoresponse_4",
               "s6q15whynoresponse_4",
               "s6q16other_4",
               "s6q16whynoresponse_4",
               "s6q17whynoresponse_4",
               "s6q19whynoresponse_4",
               "s6q18other_4",
               "s6q18whynoresponse_4",
               "s6q19awhynoresponse_4",
               "s6q20whynoresponse_4",
               "s6q21whynoresponse_4",
               "s6q14_5",
               "s6q15awhynoresponse_5",
               "s6q15whynoresponse_5",
               "s6q16other_5",
               "s6q16whynoresponse_5",
               "s6q17whynoresponse_5",
               "s6q19whynoresponse_5",
               "s6q18other_5",
               "s6q18whynoresponse_5",
               "s6q19awhynoresponse_5",
               "s6q20whynoresponse_5",
               "s6q21whynoresponse_5",
               "s6q14_6",
               "s6q15awhynoresponse_6",
               "s6q15whynoresponse_6",
               "s6q16other_6",
               "s6q16whynoresponse_6",
               "s6q17whynoresponse_6",
               "s6q19whynoresponse_6",
               "s6q18other_6",
               "s6q18whynoresponse_6",
               "s6q19awhynoresponse_6",
               "s6q20whynoresponse_6",
               "s6q21whynoresponse_6",
               "s6q14_7",
               "s6q15awhynoresponse_7",
               "s6q15whynoresponse_7",
               "s6q16other_7",
               "s6q16whynoresponse_7",
               "s6q17whynoresponse_7",
               "s6q19whynoresponse_7",
               "s6q18other_7",
               "s6q18whynoresponse_7",
               "s6q19awhynoresponse_7",
               "s6q20whynoresponse_7",
               "s6q21whynoresponse_7",
               "s6q14_8",
               "s6q15awhynoresponse_8",
               "s6q15whynoresponse_8",
               "s6q16other_8",
               "s6q16whynoresponse_8",
               "s6q17whynoresponse_8",
               "s6q19whynoresponse_8",
               "s6q18other_8",
               "s6q18whynoresponse_8",
               "s6q19awhynoresponse_8",
               "s6q20whynoresponse_8",
               "s6q21whynoresponse_8",
               "s6q14_9",
               "s6q15awhynoresponse_9",
               "s6q15whynoresponse_9",
               "s6q16other_9",
               "s6q16whynoresponse_9",
               "s6q17whynoresponse_9",
               "s6q19whynoresponse_9",
               "s6q18other_9",
               "s6q18whynoresponse_9",
               "s6q19awhynoresponse_9",
               "s6q20whynoresponse_9",
               "s6q21whynoresponse_9",
               "s6q14_10",
               "s6q15awhynoresponse_10",
               "s6q15whynoresponse_10",
               "s6q16other_10",
               "s6q16whynoresponse_10",
               "s6q17whynoresponse_10",
               "s6q19whynoresponse_10",
               "s6q18other_10",
               "s6q18whynoresponse_10",
               "s6q19awhynoresponse_10",
               "s6q20whynoresponse_10",
               "s6q21whynoresponse_10",
               "s6q14_11",
               "s6q15awhynoresponse_11",
               "s6q15whynoresponse_11",
               "s6q16other_11",
               "s6q16whynoresponse_11",
               "s6q17whynoresponse_11",
               "s6q19whynoresponse_11",
               "s6q18other_11",
               "s6q18whynoresponse_11",
               "s6q19awhynoresponse_11",
               "s6q20whynoresponse_11",
               "s6q21whynoresponse_11",
               "s6q14_12",
               "s6q15awhynoresponse_12",
               "s6q15whynoresponse_12",
               "s6q16other_12",
               "s6q16whynoresponse_12",
               "s6q17whynoresponse_12",
               "s6q19whynoresponse_12",
               "s6q18other_12",
               "s6q18whynoresponse_12",
               "s6q19awhynoresponse_12",
               "s6q20whynoresponse_12",
               "s6q21whynoresponse_12",
               "s6q14_13",
               "s6q15awhynoresponse_13",
               "s6q15whynoresponse_13",
               "s6q16other_13",
               "s6q16whynoresponse_13",
               "s6q17whynoresponse_13",
               "s6q19whynoresponse_13",
               "s6q18other_13",
               "s6q18whynoresponse_13",
               "s6q19awhynoresponse_13",
               "s6q20whynoresponse_13",
               "s6q21whynoresponse_13",
               "s6q14_14",
               "s6q15awhynoresponse_14",
               "s6q15whynoresponse_14",
               "s6q16other_14",
               "s6q16whynoresponse_14",
               "s6q17whynoresponse_14",
               "s6q19whynoresponse_14",
               "s6q18other_14",
               "s6q18whynoresponse_14",
               "s6q19awhynoresponse_14",
               "s6q20whynoresponse_14",
               "s6q21whynoresponse_14",
               "s6q14_15",
               "s6q15awhynoresponse_15",
               "s6q15whynoresponse_15",
               "s6q16other_15",
               "s6q16whynoresponse_15",
               "s6q17whynoresponse_15",
               "s6q19whynoresponse_15",
               "s6q18other_15",
               "s6q18whynoresponse_15",
               "s6q19awhynoresponse_15",
               "s6q20whynoresponse_15",
               "s6q21whynoresponse_15",
               "s6q14_16",
               "s6q15awhynoresponse_16",
               "s6q15whynoresponse_16",
               "s6q16other_16",
               "s6q16whynoresponse_16",
               "s6q17whynoresponse_16",
               "s6q19whynoresponse_16",
               "s6q18other_16",
               "s6q18whynoresponse_16",
               "s6q19awhynoresponse_16",
               "s6q20whynoresponse_16",
               "s6q21whynoresponse_16",
               "s6q14_17",
               "s6q15awhynoresponse_17",
               "s6q15whynoresponse_17",
               "s6q16other_17",
               "s6q16whynoresponse_17",
               "s6q17whynoresponse_17",
               "s6q19whynoresponse_17",
               "s6q18other_17",
               "s6q18whynoresponse_17",
               "s6q19awhynoresponse_17",
               "s6q20whynoresponse_17",
               "s6q21whynoresponse_17",
               "s6q14_18",
               "s6q15awhynoresponse_18",
               "s6q15whynoresponse_18",
               "s6q16other_18",
               "s6q16whynoresponse_18",
               "s6q17whynoresponse_18",
               "s6q19whynoresponse_18",
               "s6q18other_18",
               "s6q18whynoresponse_18",
               "s6q19awhynoresponse_18",
               "s6q20whynoresponse_18",
               "s6q21whynoresponse_18",
               "s6q14_19",
               "s6q15awhynoresponse_19",
               "s6q15whynoresponse_19",
               "s6q16other_19",
               "s6q16whynoresponse_19",
               "s6q17whynoresponse_19",
               "s6q19whynoresponse_19",
               "s6q18other_19",
               "s6q18whynoresponse_19",
               "s6q19awhynoresponse_19",
               "s6q20whynoresponse_19",
               "s6q21whynoresponse_19",
               "s6q14_20",
               "s6q15awhynoresponse_20",
               "s6q15whynoresponse_20",
               "s6q16other_20",
               "s6q16whynoresponse_20",
               "s6q17whynoresponse_20",
               "s6q19whynoresponse_20",
               "s6q18other_20",
               "s6q18whynoresponse_20",
               "s6q19awhynoresponse_20",
               "s6q20whynoresponse_20",
               "s6q21whynoresponse_20",
               "s6q14_21",
               "s6q15awhynoresponse_21",
               "s6q15whynoresponse_21",
               "s6q16other_21",
               "s6q16whynoresponse_21",
               "s6q17whynoresponse_21",
               "s6q19whynoresponse_21",
               "s6q18other_21",
               "s6q18whynoresponse_21",
               "s6q19awhynoresponse_21",
               "s6q20whynoresponse_21",
               "s6q21whynoresponse_21",
               "s6q14_22",
               "s6q15awhynoresponse_22",
               "s6q15whynoresponse_22",
               "s6q16other_22",
               "s6q16whynoresponse_22",
               "s6q17whynoresponse_22",
               "s6q19whynoresponse_22",
               "s6q18other_22",
               "s6q18whynoresponse_22",
               "s6q19awhynoresponse_22",
               "s6q20whynoresponse_22",
               "s6q21whynoresponse_22",
               "s6q14_23",
               "s6q15awhynoresponse_23",
               "s6q15whynoresponse_23",
               "s6q16other_23",
               "s6q16whynoresponse_23",
               "s6q17whynoresponse_23",
               "s6q19whynoresponse_23",
               "s6q18other_23",
               "s6q18whynoresponse_23",
               "s6q19awhynoresponse_23",
               "s6q20whynoresponse_23",
               "s6q21whynoresponse_23",
               "s6q22whynoresponse",
               "s6q23whynoresponse",
               "s6q24whynoresponse",
               "s6q25whynoresponse",
               "s6q26whynoresponse",
               "s6q27whynoresponse",
               "s6q28whynoresponse",
               "s6q29whynoresponse",
               "s6q30whynoresponse",
               "s6q31whynoresponse",
               "s6q33",
               "s6q32whynoresponse",
               "s6q34whynoresponse",
               "s6q35whynoresponse")

report_open (list_open_ends = open_ends)



# Review "verbatims.csv". Identify variables to be deleted or redacted and their row number 

mydata$s6q1whynoresponse[227] <- "The land was granted by the [LGU]."

mydata$s6q5_other[407] <- "Other"
mydata$s6q5_other[513] <- "Other"
mydata$s6q5_other[577] <- "Other"
mydata$s6q5_other[624] <- "Other"
mydata$s6q5_other[936] <- "Other"
mydata$s6q5_other[953] <- "Other"
mydata$s6q5_other[1010] <- "Other"
mydata$s6q5_other[1093] <- "Other"
mydata$s6q5_other[2000] <- "Other"
mydata$s6q5_other[2219] <- "Other"

mydata$s6q5whynoresponse[1073] <- "Other"

mydata$s6q9whynoresponse[30] <- "Out of [amount redacted] respondent only recieve [amount redacted]"
mydata$s6q9whynoresponse[1068] <- "Not definite. Depends on what owner of land asks for after assessment of harvest. Usually just a [percentage redacted]"

mydata$s6q12whynoresponse[16] <- "Other"
mydata$s6q12whynoresponse[333] <- "Other"

mydata$s6q14_1[531] <- "Other"
mydata$s6q14_1[696] <- "Other"
mydata$s6q14_1[709] <- "Other"
mydata$s6q14_1[865] <- "Other"
mydata$s6q14_1[904] <- "Other"
mydata$s6q14_1[992] <- "Other"
mydata$s6q14_1[1073] <- "Other"
mydata$s6q14_1[1235] <- "Other"
mydata$s6q14_1[1316] <- "Other"
mydata$s6q14_1[1331] <- "Other"
mydata$s6q14_1[1358] <- "Other"
mydata$s6q14_1[1421] <- "Other"
mydata$s6q14_1[1486] <- "Other"
mydata$s6q14_1[1520] <- "Other"
mydata$s6q14_1[1571] <- "Other"
mydata$s6q14_1[1641] <- "Other"
mydata$s6q14_1[1695] <- "Other"
mydata$s6q14_1[1699] <- "Other"
mydata$s6q14_1[1704] <- "Other"
mydata$s6q14_1[1715] <- "Other"
mydata$s6q14_1[1810] <- "Other"
mydata$s6q14_1[1814] <- "Other"
mydata$s6q14_1[1818] <- "Other"
mydata$s6q14_1[1901] <- "Other"
mydata$s6q14_1[1976] <- "Other"
mydata$s6q14_1[2132] <- "Other"
mydata$s6q14_1[2135] <- "Other"
mydata$s6q14_1[2228] <- "Other"


mydata$s6q16other_1[662] <- "Loan from family and friends"
mydata$s6q16other_1[671] <- "Loan from family and friends"
mydata$s6q16other_1[1514] <- "Loan from family and friends"
mydata$s6q16other_1[26] <- "Other"
mydata$s6q16other_1[55] <- "Other"
mydata$s6q16other_1[130] <- "Other"
mydata$s6q16other_1[131] <- "Other"
mydata$s6q16other_1[132] <- "Other"
mydata$s6q16other_1[262] <- "Other"
mydata$s6q16other_1[286] <- "Other"
mydata$s6q16other_1[290] <- "Other"
mydata$s6q16other_1[317] <- "Other"
mydata$s6q16other_1[320] <- "Other"
mydata$s6q16other_1[327] <- "Other"
mydata$s6q16other_1[332] <- "Other"
mydata$s6q16other_1[379] <- "Other"
mydata$s6q16other_1[422] <- "Other"
mydata$s6q16other_1[455] <- "Other"
mydata$s6q16other_1[459] <- "Other"
mydata$s6q16other_1[460] <- "Other"
mydata$s6q16other_1[475] <- "Other"
mydata$s6q16other_1[513] <- "Other"
mydata$s6q16other_1[564] <- "Other"
mydata$s6q16other_1[584] <- "Other"
mydata$s6q16other_1[587] <- "Other"
mydata$s6q16other_1[595] <- "Other"
mydata$s6q16other_1[596] <- "Other"
mydata$s6q16other_1[612] <- "Other"
mydata$s6q16other_1[614] <- "Other"
mydata$s6q16other_1[631] <- "Other"
mydata$s6q16other_1[638] <- "Other"
mydata$s6q16other_1[649] <- "Other"
mydata$s6q16other_1[650] <- "Other"
mydata$s6q16other_1[678] <- "Other"
mydata$s6q16other_1[686] <- "Other"
mydata$s6q16other_1[1367] <- "Other"
mydata$s6q16other_1[1389] <- "Other"
mydata$s6q16other_1[1395] <- "Other"
mydata$s6q16other_1[1542] <- "Other"
mydata$s6q16other_1[1588] <- "Other"
mydata$s6q16other_1[1686] <- "Other"
mydata$s6q16other_1[1824] <- "Other"
mydata$s6q16other_1[1825] <- "Other"
mydata$s6q16other_1[1828] <- "Other"
mydata$s6q16other_1[1832] <- "Other"
mydata$s6q16other_1[1904] <- "Other"
mydata$s6q16other_1[2082] <- "Other"
mydata$s6q16other_1[2129] <- "Other"
mydata$s6q16other_1[2134] <- "Other"
mydata$s6q16other_1[2215] <- "Other"
mydata$s6q16other_1[2219] <- "Other"

mydata$s6q18other_1[799] <- "Other"
mydata$s6q18other_1[840] <- "Other"
mydata$s6q18other_1[904] <- "Other"
mydata$s6q18other_1[952] <- "Other"
mydata$s6q18other_1[1358] <- "Other"
mydata$s6q18other_1[1501] <- "Other"

mydata$s6q14_2[17] <- "Other"
mydata$s6q14_2[116] <- "Other"
mydata$s6q14_2[701] <- "Other"
mydata$s6q14_2[709] <- "Other"
mydata$s6q14_2[760] <- "Other"
mydata$s6q14_2[778] <- "Other"
mydata$s6q14_2[941] <- "Other"
mydata$s6q14_2[1057] <- "Other"
mydata$s6q14_2[1073] <- "Other"
mydata$s6q14_2[1205] <- "Other"
mydata$s6q14_2[1235] <- "Other"
mydata$s6q14_2[1299] <- "Other"
mydata$s6q14_2[1313] <- "Other"
mydata$s6q14_2[1316] <- "Other"
mydata$s6q14_2[1340] <- "Other"
mydata$s6q14_2[1347] <- "Other"
mydata$s6q14_2[1417] <- "Other"
mydata$s6q14_2[1421] <- "Other"
mydata$s6q14_2[1476] <- "Other"
mydata$s6q14_2[1520] <- "Other"
mydata$s6q14_2[1553] <- "Other"
mydata$s6q14_2[1698] <- "Other"
mydata$s6q14_2[1744] <- "Other"
mydata$s6q14_2[2000] <- "Other"
mydata$s6q14_2[2024] <- "Other"
mydata$s6q14_2[2136] <- "Other"
mydata$s6q14_2[2138] <- "Other"
mydata$s6q14_2[2139] <- "Other"
mydata$s6q14_2[2221] <- "Other"

mydata$s6q16other_2[132] <- "Other"
mydata$s6q16other_2[290] <- "Other"
mydata$s6q16other_2[327] <- "Other"
mydata$s6q16other_2[459] <- "Other"
mydata$s6q16other_2[466] <- "Other"
mydata$s6q16other_2[580] <- "Other"
mydata$s6q16other_2[593] <- "Other"
mydata$s6q16other_2[599] <- "Other"
mydata$s6q16other_2[627] <- "Other"
mydata$s6q16other_2[666] <- "Other"
mydata$s6q16other_2[1828] <- "Other"
mydata$s6q16other_2[2218] <- "Other"

mydata$s6q18other_2[638] <- "Other"
mydata$s6q18other_2[657] <- "Other"
mydata$s6q18other_2[675] <- "Other"
mydata$s6q18other_2[1068] <- "Other"
mydata$s6q18other_2[1113] <- "Other"
mydata$s6q18other_2[1905] <- "Other"

mydata$s6q18other_3[1367] <- "Other"
mydata$s6q18other_3[1831] <- "Other"
mydata$s6q18other_3[2268] <- "Other"

mydata$s6q18other_4[1345] <- "Other"
mydata$s6q18other_4[1367] <- "Other"
mydata$s6q18other_4[1831] <- "Other"

mydata$s6q19awhynoresponse_5[1235] <- "[Language]"

mydata$s6q14_12[1477] <- "[Language]"

mydata$s6q14_21[1477] <- "[Language]"

mydata$s6q14_23[1477] <- "[Language]"

mydata$s6q24whynoresponse[2046] <- "He only knows the total amount which is [amount redacted] for 12 months"

mydata$s6q26whynoresponse[2046] <- "He only knows the total amount which is [amount redacted] for 12 months"

mydata$s6q30whynoresponse[1085] <- "Only the hudband and wife are working in the farm and also there son [name]"
mydata$s6q30whynoresponse[2046] <- "He only knows the total amount which is [amount redacted] in 12 months"

GPS data: Displace

# !!!No GPS data

Save processed data in Stata and SPSS format

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)