rm(list=ls(all=t))
filename <- "midline2" # !!!Update filename
functions_vers <- "functions_1.7.R" # !!!Update helper functions file
source (functions_vers)
Visually inspect variables in "dictionary.csv" and flag for risk, using the following flags:
# Direct PII: Respondent Names, Addresses, Identification Numbers, Phone Numbers
# Direct PII-team: Interviewer Names, other field team names
# Indirect PII-ordinal: Date of birth, Age, income, education, household composition.
# Indirect PII-categorical: Gender, education, ethnicity, nationality,
# occupation, employer, head of household, marital status
# GPS: Longitude, Latitude
# Small Location: Location (<100,000)
# Large Location (>100,000)
# Weight: weightVar
# Household ID: hhId,
# Open-ends: Review responses for any sensitive information, redact as necessary
# !!!No Direct PII
# !!!No Direct PII-team
!!!Include relevant variables, but check their population size first to confirm they are <100,000
mydata$mid2_child_municipality <- as.numeric(mydata$mid2_child_municipality)
locvars <- c("mid2_villagename",
"mid2_settlement",
"mid2_municipality",
"mid2_wardno",
"mid2_child_municipality",
"mid2_child_wardno",
"mid2_child_villagename",
"mid2_child_settlement")
mydata <- encode_location (variables= locvars, missing=999999)
## [1] "Frequency table before encoding"
## mid2_villagename. Villagename
## Aadarsa tol Aadarsha tol aadarshnagar
## 5 8 1
## Aadrash tole Aakala Aalau
## 6 5 28
## aarba Aarba Adalat road
## 7 6 3
## Adarshnagar akala Apauni
## 4 11 11
## arba Arba arbaa
## 13 4 2
## Armalakot arva Ashokbatica
## 5 24 10
## Ashokbatika Atharaha athraha
## 12 11 8
## Athraha Bahuwari Baisno devi tole
## 43 11 4
## bajo khet Bajrang tole Balgenari
## 3 19 1
## Banahari Bangau bankatta
## 13 24 1
## Barabighaha Barwa Basant inarwa
## 3 8 8
## Basantpure Basudavpur Basudevpur
## 9 5 92
## Bausevpur Bawaniyapur Bayo khola
## 2 7 20
## Belganari Beltakura Bhagawati tole
## 6 5 4
## Bhagwatitol bhakti path bhalam
## 28 4 19
## Bhalam bhandari dhar bhansartole
## 32 6 6
## Bhansartole bhastal bhati path
## 15 13 3
## Bhawanipir Bhawanipur Bhawaniyapur
## 6 76 84
## Bhediyahi Bhiswa Bijayanagar
## 7 1 5
## Bijeynagar Bindabasini Bindawasini
## 50 47 12
## birendra gufa Birgunj Birta
## 17 30 66
## Birta bazà r Brahmpur Bundabasini
## 7 50 1
## Center parseni tol Chailai chanautae
## 5 15 14
## Chanora parariya chanute chapkaiya
## 14 5 4
## Chapkaiya Chapkaiys Chapksiya
## 169 6 7
## Chhapkaiya Chitraguptnagar chour
## 122 16 5
## chowk Chowk bhola Dabar tole
## 1 1 4
## Dadathok Dadrini Danda sukaura
## 1 4 9
## Daxin nawalpur tole Deurali piple Devi chook
## 3 14 5
## Dhadagari Dhaddagari dhaurali
## 12 6 4
## Dhurmi Dihi gau Dripot
## 32 2 9
## dripot sirsiya Fulbari Furathi chook
## 7 73 1
## Furthi chook Furthichook Furtichook
## 33 1 4
## Gahatera Gahawa garjati
## 5 23 7
## Garmikhola gauri khor Gaurigau
## 8 3 14
## Gaushwara Geetanagar Geetanagr
## 7 168 4
## ghadhai Ghadi ghanduke chouk
## 6 4 3
## Gharimukhla Ghariwara Ghariwarha
## 3 16 14
## Gharmikhola ghatgai Ghoraneti tol
## 4 5 15
## Ghorneti Ghusari Ghushauri tole
## 1 8 5
## Gogimani Golauri Golouri
## 4 5 5
## Gopal chook Gshawa haldharko chautara
## 6 5 1
## Halwar hanuman nagar hanumanagar
## 3 10 20
## hanumannagar Haripaura Haripauri
## 6 9 5
## Harpatganj Harpatgunj Hasnapur
## 40 21 14
## Hatiya Hemanagar Hemangar
## 30 6 4
## hemja Hemja Himalay tole
## 40 91 16
## Himaltole Himalya tole Indarpue
## 6 1 5
## Indarpur Jail road Jail tol
## 107 5 1
## Jailroad Jaispur Jaspur
## 5 94 9
## Jaumare Jumleti Kachila
## 9 11 23
## Kachili Kahu kahun
## 19 34 19
## Kalakhola Kalimati Kaltu pokhari
## 4 6 1
## Kanchanpur road Kaprae ghat Kataha
## 5 4 14
## kaun Kawari Kesarbagha
## 38 8 1
## Khadre Khadrye khaluwatole
## 4 12 8
## Khaluwatole sirsiya khalwa sirisiya khalwa tol
## 6 9 5
## Kharkhola Kharsal Kharsal tole
## 3 80 3
## Khas karkandoo khastar khaster
## 89 6 9
## Kirana line Kirishna nagar Koeritole udaypur ghurmi
## 1 5 11
## kristi Kristi Kuhari
## 37 51 3
## Kumal gau Kumar tole Kumhal tol
## 2 1 10
## Kumhaltole Kwangi Kwongi
## 6 7 5
## Kwonig Lachhamanu Lachhamsnu
## 6 19 1
## Lalmateya Lalmatya Lamachaur
## 4 5 6
## Lamaswara Mahabir sthan Mahabirsthaan
## 4 6 25
## Mahabirsthan Maisthaan Maisthan
## 1 8 87
## Manaidada Manakamana tol Mandantole
## 3 3 1
## Mangalpur Manihari Manikapir
## 31 41 4
## Manikapur Mathaelno halwar tol Maujetole
## 100 4 19
## methlang Methlang Mohonpur
## 6 5 5
## Motipur Murli Murlibagaica
## 11 43 11
## Murlibagaicha Murlibhagaicha Musilamtol
## 29 8 7
## Muslimtol Nabin chook Nagarpalika road
## 33 7 46
## Nagawa Naguwa Nagwa
## 5 77 21
## Namuna tole Naulpur Naya tole mruli
## 5 14 1
## Nayagaun nirmal pokhari Nirmal pokhari
## 10 23 25
## nirmalpokhari Nirmalpokhari padale
## 5 21 3
## padam pokhari padampokhari Paddha
## 11 4 11
## padhali Padham pokhare Parariya
## 16 1 6
## Parasnagar Paraspur Park as,nagar
## 6 86 4
## Parkash,nagar,sano basti Parks,nagar,Sano,pipra Parsauni
## 1 6 33
## Parwanipur ParwaniPur Paschim rampur
## 119 1 25
## Patahani patihani Patihani
## 3 52 150
## patihani town patiheni patlahara
## 10 7 6
## Pipara Pipara,aawas,ariya Pipra
## 36 1 4
## Piprahwa pokhara Pokharel tole
## 119 8 4
## Pokheral tole Pokherel tole Pokhral tole
## 16 3 4
## Pokhrel tole Prasauni Pulchowk
## 4 20 6
## Pumdhi Pumdi Pumdi bhumdi
## 5 16 5
## Pumdi vumdi Pumdibhumdi Pumdikot
## 15 3 3
## pundi vundi Puraina Puraini
## 22 147 135
## Purba rampur Puripokhari Purnipikhari
## 1 4 5
## Purnipokari Purnipokhari Raam tole
## 4 6 5
## Raampur Radhemai Rahamatpur
## 17 48 19
## Raikhalyan Raikhelyan Rajbiraj
## 5 1 213
## Rajbiraj Kharsal Rajdevi Rajdevi road
## 5 4 8
## Rajdevi tol Rajdevi tole Rajiraj
## 5 43 10
## Ram tole Ramgaduwa Ramgadwa
## 1 98 26
## rampur Rampur Rangasala tole
## 4 12 1
## Ranighat Ranighat tol Ranighat tole
## 156 10 8
## Resamkoti Resham kothi Reshamkhoti
## 10 26 7
## Reshamkothi Reshamkoti ReshamKoti
## 6 28 1
## Ryale patle Ryale Patle Sabaithuwa
## 6 5 7
## Sabaituwa Sabauthuwa sahar dhar
## 11 9 5
## Saibutwa Saikrishana tole Sajha tole
## 12 1 3
## santipur Saorn tole Saptaha ko dil
## 7 5 5
## sarangkot Sarangkot Sarankot
## 18 15 6
## Saranpur Saraswati tole Sarboday tole
## 30 4 7
## Sardar tole sardhar Sarswati tole
## 4 16 21
## sauda chautra Shanti gyan bikash tol Shekh
## 5 3 1
## Shiavanagar Shimra gaun Shiromaninagar
## 4 5 13
## shirsiya shiva nagar Shiva sakti tole
## 4 15 4
## Shivaghat shivanagar Shivanagar
## 4 15 88
## Shivdakti tole Shivnagar Shreepur
## 3 4 51
## Shreepur,ranighat Simlegaira Sirbani
## 3 7 7
## Sirshiya Sirsiya Sisobari
## 20 15 14
## Sitalapur Sitalpur Sivanagar
## 4 5 41
## Srawati tole Sreepur srisiya vansar tol
## 7 30 8
## Srswati tole Suagauli birta Subash shah
## 3 7 1
## Sugali Sugali birta Sugauli
## 8 17 35
## SUGAULI Sugauli birta Sukaura
## 4 22 6
## Sundar basti tole Sunderbasti Suryodaynagar
## 7 10 1
## Swarn tole swikhet swikot
## 39 8 3
## Talno halawar Talno halwar tol Tarigain
## 5 8 10
## Tarigau Tarigau sano rajeura Tarigau tharu gaun
## 57 4 5
## Tarigaun Tejara tole Tejarath tole
## 18 1 9
## Tejaratole Tejrath tole Tetari gachhi
## 17 7 5
## Tetri gachi Tetrigachi Thapa tol
## 5 4 21
## Tharu gau tol Uday pur ghurmi Udayapur
## 12 5 127
## Udayapur ghurmi Udaypur Udaypur bhurmi
## 10 32 9
## Udaypur ghurmi Udaypur Gurmi Urahari
## 31 9 28
## Utarsukaura Uttar nawalpur tole Uttar sukaura
## 3 6 8
## valam Valam Valuwahi tole
## 12 25 5
## Vansar sirisiya Vanshar sirisiya vhimsen nagar
## 3 1 5
## vimshennagar Vishwa Viswa
## 1 9 3
## yamdi yamdi tol
## 4 3
## [1] "Frequency table after encoding"
## mid2_villagename. Villagename
## 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
## 6 1 19 5 1 7 5 7 20 94 4 12 1 16 25 9 5 4
## 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
## 3 4 6 5 1 11 17 5 5 12 9 4 3 7 5 4 28 26
## 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689
## 6 20 18 4 8 11 41 4 15 119 4 10 11 5 25 7 6 35
## 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
## 29 4 12 7 5 1 36 4 5 5 2 8 169 8 1 4 1 13
## 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
## 31 6 7 25 6 17 32 5 5 76 107 100 5 5 19 9 5 80
## 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743
## 6 4 7 5 7 15 3 5 11 1 57 24 1 4 5 47 1 15
## 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761
## 5 4 50 4 8 7 6 9 7 38 3 34 1 4 4 4 4 10
## 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779
## 6 11 6 9 5 7 1 1 11 5 11 12 6 5 10 4 3 7
## 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
## 10 1 11 5 40 5 8 4 3 30 16 7 43 4 1 13 8 4
## 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815
## 5 32 8 5 5 18 22 147 43 5 5 5 4 3 7 19 7 77
## 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833
## 8 7 4 22 8 6 14 14 3 14 21 11 135 9 5 5 6 30
## 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
## 4 30 1 5 213 14 3 6 14 20 15 6 23 14 4 5 3 14
## 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869
## 28 5 8 43 4 3 10 12 46 1 5 3 4 21 5 8 87 3
## 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887
## 39 33 6 12 5 3 15 8 21 6 26 9 4 28 5 1 4 12
## 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905
## 1 66 32 14 1 1 30 7 4 1 8 6 1 9 9 23 52 25
## 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923
## 127 6 6 40 3 6 1 16 4 17 33 7 5 12 5 15 10 9
## 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941
## 19 10 31 20 19 3 3 1 10 3 19 19 1 6 89 50 119 41
## 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
## 4 3 11 84 3 6 4 6 11 6 28 2 10 9 6 15 1 51
## 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977
## 1 3 7 3 4 73 13 8 16 8 17 88 15 150 1 3 1 7
## 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995
## 5 5 2 4 5 4 4 37 9 1 51 156 5 10 1 10 91 48
## 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
## 1 1 4 6 6 168 16 92 4 6 4 8 1 16 3 3 1 21
## 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031
## 122 5 5 6 9 3 2 3 3 21 6 5 7 4 13 14 23 98
## 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045
## 33 5 8 3 6 4 24 16 86 1 1 5 8 7
## [1] "Frequency table before encoding"
## mid2_settlement.
## Aadarsamani Aadarsapokhrel Aadarsh tole
## 3 4 6
## aadarshnagae aadhars tol Aalam
## 1 4 1
## Aalau Aanapurna Tol Adalat road
## 28 4 3
## Adarsha mani tol Adarshnagar Ahmad tole
## 14 4 1
## akala akla Alanagar
## 6 5 12
## Amarapuri Amarbasti Ammarbasti
## 1 2 13
## annapurna tol Apauni arbhote
## 4 25 4
## Armalakot Ashokbatika Atharaha
## 5 22 11
## athraha Athraha Babaitol
## 8 43 1
## Babu gaun Babugaun Badahare
## 29 13 3
## Badalthar Badare Bagaicha
## 4 5 5
## Bagale lamaswara Bagbani tol Bahaya khola
## 4 1 3
## baheri Bahu khola Bahueari
## 1 3 6
## Bahuwari bajhare Bajrang
## 5 5 3
## Bajrang tole Bajrangi tole Bale gaun
## 8 12 21
## Balegaun Banahari Bangau
## 39 4 12
## Banjare gaau bankatta Banpale
## 25 1 5
## barabuta Barampuri Barauji
## 5 13 24
## Barewa Basantpure Basbot
## 23 9 9
## Baseri bastal Bawan tol
## 8 13 1
## Bayo khola Bhadagau Bhagawan Tola
## 20 4 12
## Bhagawati tole Bhagwatitol bhajo khet
## 4 28 3
## bhakti path Bhaktipath bhalam
## 4 6 13
## Bhandari bhandari dhar Bhanichok
## 3 6 5
## bhanjyang tilahar tol Bhansartol bhansartole
## 5 6 6
## Bhansartole Bhanuchowk bhati path
## 15 9 3
## Bhawanipur Bhayakhola Bhayapur
## 18 5 5
## Bhediyahi Bhiri road Bhiswa
## 7 8 2
## Bhitri road Bhujai gaun Bhujaigaun
## 6 3 10
## Bhuji gaun Bhujigaun Bhuyarmandir tol
## 7 8 3
## Bidhyapith school paxadi Bijeynagar Bindawasini
## 5 12 20
## birendra gufa Birta BIRTA
## 17 93 4
## Bishnupur bodhare botetol
## 10 8 11
## Bramtol Britakhet Buketi
## 1 3 4
## Campus gali Chahari chook Chailai
## 1 6 8
## Chamar tol and dhobi tol chanatae chanautae
## 14 5 9
## Chanora parariya chanute Chapa
## 14 5 5
## Chapkaiya bazar Chapkaiya kawadi tol Chapkaiya tol
## 7 7 1
## Chapkaiya tôle Chhapkaiya Chilaune kharka
## 1 32 3
## chilaunekharka Chimeki tol Chiranjivi chowk
## 5 4 8
## Chitraguptnagar chour chowk
## 16 5 1
## Cold store Copan gunj Dabar
## 21 6 4
## Dadathok tol Daddhagari Dadre
## 1 1 5
## Dadrini tol Dakshin tole Damodar
## 4 10 3
## Dandagaun tol Dandathok Dangisaran tol
## 3 3 3
## Darahi tol daredeurali Dasarathnager
## 3 4 3
## Devichook Devichowk Devnagar
## 1 6 19
## Devthan Devthan tlo Dhadagari
## 3 5 6
## Dhaddagari dhakalthar dhaurali
## 5 6 8
## Dhore gaun Dihi Dr koloni
## 28 2 6
## Dripot Dumari Dumri
## 9 22 43
## Duwar Duwar tol foksing deurali
## 5 5 2
## Fulbari Fulbari tol Furthi chook
## 17 5 26
## Furthi cook Futaha Gadash tol
## 6 3 6
## Gahatera Gail road Gairiswara
## 5 5 2
## Ganaganagar Ganesh chok Ganesh marg,trichowk
## 5 5 9
## Ganesh tole Ganeshgunj Ganganagar
## 5 9 37
## Gangapur Gangarampura Gangarampurwa
## 29 9 10
## garbetandi garjati Gaucharan
## 4 7 4
## gauri khor Gaurigau Gaushwara
## 3 10 7
## Gayatri tole Geeta mandir Geetanagar
## 10 1 5
## Geetanagar bazar ghadgai Ghalegaun
## 6 6 1
## ghandruke chouk Ghariwara Ghariwarha
## 3 16 14
## ghatgai Ghoradabra tol Ghoraneti
## 5 1 15
## Ghorneti Ghurmi Ghusauri
## 1 28 5
## Ghushari Ghusukpur Gopal chook
## 8 18 6
## Gopalgunj Gorkhali Gorkhali tole
## 16 35 43
## Gouripurwa Gumbachour Gurung gau
## 6 3 12
## Gyarjati gyarjyoti Gyatrinagar
## 6 1 4
## Hal pachadi Halawar haldharko chautara
## 6 5 1
## Halwar hanuman nagar Hanuman nagar road
## 15 10 12
## hanumanaga hanumanagar hanumannagar
## 5 6 10
## Haraiya way Haripaura Haripauri
## 1 5 5
## Harpatganj Harpatgunj Hasnapur
## 14 21 7
## Hatiya Hemanagar Himalay
## 30 6 1
## Himalay tole Himalaya Himalaya tole
## 20 1 4
## Himaltole Himalya tole Hulaki tol
## 6 1 5
## Hulakimarg Inaruwa Inaruwamaniyari
## 12 22 38
## Inarwa Indargaau Indrapuri
## 8 28 14
## Indrapuri chok Jagaran jagriti
## 1 4 1
## jagriti tol Jagriti tol Jagritinagar
## 4 5 4
## Jail tol Jailroad Jaimare
## 1 5 4
## Jaispur Jamnaha Janajagaran tol
## 94 30 13
## Janakeswori Jaspur Jayanagar
## 3 9 17
## Jayananesh Jaynagar Jelrod
## 4 1 4
## Jhanjhane Jodhapurwa joti chock
## 11 12 1
## Jumleti Kabadi tol Kachili
## 11 6 5
## Kachili tol Kalakhola Kalikhola
## 5 4 8
## Kalimati Kaltu line Kaltu pokhari
## 13 1 4
## kamere pani tol Kanchanpur road Kanchi chok
## 5 5 6
## Kanthipur Kantipur Kantipur tol
## 16 5 4
## Kapadevi tol Kapre chat chook Karkandoo
## 4 4 13
## Karki chok karki gaun Karkichok
## 7 3 1
## karkigau Karmohna kaseri
## 3 13 4
## Kaseri kaseri tol kaster
## 1 1 3
## Kataha sami tol Katilya Kaulash chok
## 1 14 10
## kaun deurali kaun tol Kawari
## 3 12 8
## Kehuniya Kesarbagha Kesharbag
## 25 1 18
## Khadkathar Khadrya Khalla Puraini
## 7 3 9
## Khalla Puraini khaluwatole Khaluwatole
## 56 7 6
## khaluwatole sirsiya khalwa sirisiya Khalwa Tol
## 8 9 9
## khalwa tol sirisiya Khalwatole Kharkhola tol
## 5 11 3
## Kharsal Kharsal methil tole Kharsal tole
## 37 4 43
## Khas karkandoo khastar khaster
## 4 6 6
## Khatri gau khatri tol Khayarghari
## 3 4 17
## Khayarghari chowki Khlwatole Khora
## 4 6 4
## Kigrinpurwa Kirana line Kodi
## 18 1 3
## Koeritole Koeritole udaypur ghurmi kohadi
## 8 11 10
## Kohadi Koiri tole Koiripatti
## 32 33 22
## Krishnamandir tol Krishnamandir tole Kuhari
## 1 8 3
## Kukunswara kulain marga Kulain marga
## 5 3 4
## Kulainmarga kulayan kulayan marg
## 2 4 7
## kulayan marga kulayan tol Kulayen tol
## 2 9 3
## Kumal Kumar tole Kumhal tol
## 2 1 10
## Kumhaltole kumiya Kusanchour
## 6 6 4
## Kusinchour Laath gaali Laath gali
## 12 35 6
## Laathgaali Lachhamanu Lagdahawa
## 8 20 12
## Lagdhawa Lalapurwa laliguras tol
## 32 27 3
## Laligurash lama khet Lamachowk
## 1 1 8
## Lamakhet Lamichane thar Lamichane tole
## 6 4 1
## Laxman tol Lilja tole Lodhai gau
## 5 5 20
## Lonionpurwa Loniyan purawa Loniyanpurwa
## 5 12 21
## Loniyonpurwa Luxman tol Luxmannager
## 5 1 4
## Maanpur machapuchre tol Machapuchre Tol
## 16 6 1
## Machhapuchre tol Magartole Mahapurwa
## 8 6 24
## Mai mandir tol Main road Mainroad
## 19 23 10
## Maisthaan Maisthan Majida tol
## 7 41 4
## Malpot tole Manaidada Manakamana chook
## 5 3 1
## Manakamana tol Mandaltole Mangalpur
## 8 1 1
## Mangalpur bazer Mangalpur vitra Manihari
## 14 2 33
## Manihari tol Manikapur manisibalaya tol
## 4 30 6
## Mannipur mansara tol Masjid tole
## 10 1 15
## Mathighar Maujetole Maujetole sirsirya
## 7 12 8
## Maula maula tol Maula tol
## 4 4 6
## methlang Milan tol Milantol
## 9 14 1
## Milijulichok Milijulichowk Minabazar
## 2 6 4
## Mohanpur Mohonpur tol Moti tol
## 26 5 3
## Motitol Moujetole Murli
## 8 6 43
## Murlibagaicha Murlibhagaicha Musilamtol
## 40 8 7
## Muslimtol Nabajoti tol Nabin chook
## 33 6 4
## Nabin chook vitra nachnechaur Nachnechaur
## 3 10 3
## Nachnichour Nadai gaun Nadaigaun
## 4 1 6
## Naditole Nagarpalika road Nagawa
## 1 46 5
## Naguwa Nagwa Naharpurwa
## 29 32 4
## Namuna Namuna tol Namunatol
## 5 13 16
## Narbadha tol Natanpurwa Nawalpur
## 3 32 9
## Nayabasti Nayagaun Nayatole murli
## 10 10 1
## Neuli tol nirmal pokhari Nirmal pokhari
## 6 14 1
## Nirmalpokhari Nursery chowk Pabitra tol
## 4 7 9
## padale padam pokhari Padam pokhari
## 3 5 1
## padampokhari Padampokhari Paddha
## 4 25 1
## padeli padhali Padham pokhare
## 4 16 1
## Pakaudi Pande ghumti Panitanki
## 6 6 23
## Panitanki,chamartol Parariya Paraspur
## 7 6 39
## Parbatinagar Pargati tol Park as,nagar sanopipra
## 5 4 4
## Parsanpurwa Parsauni Parseni
## 6 33 15
## Parwanipur ParwaniPur Pasupati
## 33 1 5
## Patel,nagar Patelnegar patihani
## 7 4 8
## patihani bazar patihani town Patihani town
## 29 10 5
## patiheni bazar patlahara Phokshing
## 7 6 4
## Pipaldali Pipara Pipra
## 8 12 4
## Pokharel tole Pokheral tole Pokheral tole
## 4 4 16
## Pokherel tole Pokhrel tole Pothedarpurwa
## 3 8 16
## Pragatitol Pragtinagar Prasauni
## 4 21 19
## Professor colony Prssauni Pulchowk
## 4 1 6
## Pumdi kot Pumdikot Punari pokahri
## 4 11 4
## punti dada Puraina Puraini
## 5 81 19
## Purba rampur Purnipokari Purnipokhari tole
## 11 5 14
## Raahamatpur Raam tole Raampur
## 5 5 17
## Radakrishna Radakrisna Radha krishna Tol
## 6 5 5
## Radhakrishna radhakrishna tol Radhakrishna tol
## 1 8 6
## Radhakrishna tole Radhakrisna radhakrisna tol
## 5 3 5
## Radhapur Radhemai Rahamat tol
## 47 48 4
## Rahamatpur Rahsmad tol Raikhelyan
## 14 7 1
## Rajaura sano gaun Rajdevi Rajdevi tole
## 1 20 5
## Rajdevi road Rajdevi tole Rajhanatol
## 4 26 5
## Ram tole ramchok Ramchowk
## 5 4 1
## Rameshorpurwa Ramgaduwa Ramgadwa
## 26 91 26
## rammandir Ramtole Ramwapur
## 5 16 30
## Rangaduwa Rangasala tole Ranighat
## 7 1 162
## Ranighat tole Resham khoti Resham kothi
## 5 10 19
## Reshamkhoti Reshamkothi Reshamkoti
## 2 18 29
## Ryale Ryalechaur tol Sabaithuwa
## 6 5 16
## Sabaituw Sabaituwa Sagaramatha tol
## 1 22 6
## Saikrishana Sajha sajha tol
## 1 1 11
## Sajha tole sangam tol Sangam tol
## 3 1 6
## Sano ganeshganj Sano ganeshgunj Sano ganeshjung
## 5 1 1
## Sano gaun Sano pipra Sano Rajauara
## 5 6 4
## Sano,pipra Sanogarhi Sanogau
## 1 5 6
## santaneswor tol Santinagar santipur
## 8 4 11
## Saptaha ko dil Saranpur Sarbodai tole
## 5 1 7
## Sardar tole sardhar Sarswati tole
## 4 21 18
## Satyanarayan tole saudaha saudha chautara
## 1 4 5
## Sauraha Saworn tole Seara
## 19 5 6
## Shanti Shanti tol Shantichowk
## 9 12 10
## Shantitol Shepas patel Shimra gaun
## 3 1 5
## Shinagar Shiromaninagar Shiromaninager
## 3 9 4
## Shiva choka Shiva sundar Shiva sundar Tol
## 4 4 5
## Shivanagar Shivasakti Shivashakti tol
## 37 3 7
## Shivthan Shreepur sibalaya
## 34 61 5
## Sibalaya simalchaur Simalchaur
## 4 9 9
## simalchaur tol Simalchhaur simnasara
## 4 6 1
## sirbani Sirbani Sirha road
## 3 7 1
## sisneri sisneri tol Sisobari
## 2 4 15
## Siswadi Sitalpur Sitalpur.tol
## 3 9 4
## Srawati tole Sreepur Srijana nagar
## 7 30 12
## Srswati tole Srswati tole Sugauli
## 3 6 12
## Sugauli birta Suikhet Suiya
## 53 15 51
## Sukaura tol Sukhet Sukreseori tol
## 3 1 4
## Sukresori Sukumbasi tol Sukyatol
## 5 5 4
## Sunaulo tol Sundada sundada khet
## 3 3 4
## Sundar chok sundar santi chock Sundarbasti
## 4 4 7
## Sunderbasti Surgigaun Suryanagar
## 47 6 7
## Suryodaynagar Suuya suwara
## 1 4 4
## Swara swara tol swaraha
## 5 1 5
## swaraha dandathok Swarn tole swekhet
## 3 39 6
## swikhet swikot Syalghari
## 8 3 11
## Taajpur Tadi bisauna talla chaur
## 42 1 1
## tallo yamdi Tangparsi Tangpasri
## 1 5 40
## Tarigau tharugau Tejara tole Tejarath
## 6 1 9
## Tejaratole Tejrath Telipatti mass
## 17 7 8
## Teliyanpur Tetari gachhi Tetrigachi
## 16 5 9
## thanapati tol Thapa tol thapatilar
## 4 21 1
## Thaple tilahar Tharugau Tharugaun
## 7 13 11
## Thukaila Thula chawor tol Thulachhaur
## 12 3 4
## Thulibesi marga Thulo ghadi Thulo pipara
## 4 4 24
## Thutitol Tilahar Timalichour
## 3 8 10
## Treebeni tol Tribeni tol Tumke
## 4 9 9
## Udaypur Udaypur bhrumi Udaypur ghurmi
## 7 3 18
## Udaypur gurmi Udaypurbhurmi Ujjalnagar
## 9 6 7
## Ujjwaknagar Ujjwalchok Ujjwalnagar
## 4 5 49
## UjjwalNagar Ujjwanagar Upauni
## 3 1 12
## Urahari Urahari gothua danda Urahari rajmarg tol
## 4 3 7
## Urahari thulo gaun Utarsukaura Uttar sukaura
## 1 3 8
## Vagawanpur Valuwahi tole Vangushara
## 4 5 15
## Vansar sirisiya vansar tol Vatha tole
## 4 8 8
## Vawanpur Vidhyapith Vidhyapith school
## 9 8 12
## vimshen nagar vimshennagar Vishwa
## 7 10 9
## Viswa Yakle bel Yaklya sal
## 3 3 5
## Yamdi yamdi tol Yamdi tol bikash
## 8 7 4
## Yatimkha tol Ystimkhana tol
## 10 6
## [1] "Frequency table after encoding"
## mid2_settlement.
## 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
## 3 5 6 1 5 14 3 32 11 11 12 23 9 2 9 1 4 6
## 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
## 6 5 8 9 6 6 6 5 28 10 6 3 8 19 1 1 8 43
## 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
## 12 1 28 5 39 5 5 11 5 6 33 5 5 1 5 21 2 5
## 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
## 7 1 61 43 3 3 3 1 1 5 2 28 47 1 3 24 4 11
## 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
## 13 46 1 5 4 26 5 1 29 3 14 22 3 3 16 18 6 9
## 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
## 4 6 5 4 7 9 12 4 6 9 13 7 8 4 2 10 7 81
## 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605
## 10 49 1 6 4 22 10 8 8 29 4 25 6 21 5 1 28 7
## 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623
## 1 5 7 1 6 8 5 4 17 4 11 5 6 2 4 12 6 4
## 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
## 5 3 8 17 16 1 6 1 20 4 1 8 5 4 5 4 5 5
## 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
## 10 22 7 6 5 6 13 1 4 15 39 10 3 1 16 8 4 5
## 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
## 10 4 5 7 8 25 11 5 1 3 8 33 3 3 18 5 1 3
## 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695
## 8 42 1 6 18 3 1 12 3 6 24 1 14 5 14 4 8 4
## 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713
## 6 6 9 16 1 15 5 3 15 1 6 3 5 1 12 3 6 4
## 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731
## 3 16 16 5 4 12 6 4 4 8 10 2 30 5 4 3 30 32
## 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749
## 8 22 4 12 3 1 10 3 37 20 14 9 6 6 13 4 3 8
## 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
## 5 5 5 5 5 6 12 9 4 3 9 4 2 28 93 9 32 5
## 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785
## 7 5 10 1 3 9 18 3 8 7 1 5 1 12 10 6 3 1
## 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803
## 6 25 7 18 1 23 1 3 1 7 9 1 5 14 91 6 30 43
## 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
## 7 8 1 29 8 20 7 8 6 1 5 1 9 15 14 19 11 8
## 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839
## 5 6 22 3 40 13 3 5 4 12 7 23 3 12 3 6 9 1
## 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
## 15 1 10 6 8 6 1 6 1 24 1 4 7 33 20 6 5 4
## 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875
## 5 1 1 8 19 7 5 4 30 1 3 6 7 94 11 10 4 17
## 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893
## 5 6 4 6 9 6 9 7 3 11 11 3 3 35 3 10 48 10
## 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911
## 8 20 3 21 6 19 5 6 7 8 5 12 3 5 4 4 5 1
## 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929
## 12 5 3 40 10 4 35 6 8 4 18 1 1 1 9 26 8 4
## 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947
## 1 53 4 8 3 5 17 4 12 5 56 4 7 5 7 7 6 10
## 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965
## 1 9 4 4 5 1 4 8 6 19 4 3 9 4 13 1 4 5
## 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983
## 5 3 16 8 12 39 37 6 32 6 4 3 7 3 2 4 1 6
## 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001
## 10 4 3 14 4 10 4 13 1 21 5 29 21 4 1 3 4 4
## 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019
## 9 37 26 16 4 5 8 5 9 4 16 9 5 7 43 4 4 3
## 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037
## 4 7 15 1 1 15 4 47 5 16 4 1 20 5 7 3 14 6
## 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
## 4 32 3 4 4 4 5 14 33 14 5 1 4 34 2 4 1 1
## 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
## 9 4 2 51 12 10 6 4 11 3 4 1 1 13 38 7 26 4
## 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091
## 2 8 13 3 5 21 5 1 5 8 4 1 1 13 5 25 3 5
## 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109
## 9 41 2 1 4 12 4 5 1 10 4 3 19 5 4 5 9 1
## 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127
## 1 13 6 1 4 1 12 7 11 4 7 3 1 6 30 1 1 4
## 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145
## 5 6 33 8 1 8 43 4 162 4 21 5 1 3 27 7 4 17
## 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
## 1 4 3 16 1 9 4 3 4 4 16 18 4 1 4 3 6 5
## 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181
## 7 4 6 6 1 29 5 5 17 9 7 4 6 6 4 5 6 6
## 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
## 14 5 15 1 4 6 5 4 12 5 3 3 5 5 6 12 10 3
## 1200 1201
## 5 26
## [1] "Frequency table before encoding"
## mid2_municipality.
## 1 2 3 4 5 6
## 1028 2542 1221 961 743 641
## [1] "Frequency table after encoding"
## mid2_municipality.
## 747 748 749 750 751 752
## 1221 961 743 641 2542 1028
## [1] "Frequency table before encoding"
## mid2_wardno.
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
## 172 195 211 113 98 118 117 141 114 157 39 185 175 159 203 265 238 364 437 396 309 269
## 23 24 25 26 27 28 29 30
## 323 381 307 372 413 416 321 128
## [1] "Frequency table after encoding"
## mid2_wardno.
## 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
## 203 185 269 372 238 117 309 364 172 114 141 118 128 157 437 396 195 307 98 321 416 175
## 133 134 135 136 137 138 139 140
## 323 265 413 39 211 113 381 159
## [1] "Frequency table before encoding"
## mid2_child_municipality.
## 1 2 3 4 5 6 <NA>
## 19 6 14 16 15 6 7060
## [1] "Frequency table after encoding"
## mid2_child_municipality.
## 497 498 499 500 501 502 <NA>
## 6 6 15 19 14 16 7060
## [1] "Frequency table before encoding"
## mid2_child_wardno.
## 1 3 4 5 6 9 12 13 15 16 18 19 20 21 22 23 24 25
## 3 1 4 1 1 7 4 2 5 4 2 5 8 2 1 10 1 7
## 26 28 <NA>
## 6 2 7060
## [1] "Frequency table after encoding"
## mid2_child_wardno.
## 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
## 1 1 7 3 2 7 6 5 1 4 1 8 2 4 10 4 2 2
## 852 853 <NA>
## 1 5 7060
## [1] "Frequency table before encoding"
## mid2_child_villagename. Villagename
## Aadrash tole Basantpure bhalam Bhalam
## 7060 2 2 1 1
## Bijeynagar chanautae Chhapkaiya Deurali piple dhaurali
## 2 2 2 1 1
## Fulbari Furthi chook Ghariwara Gopal chook hanumanagar
## 3 2 2 1 2
## Indarpur Kahu kaun Kharsal Kirishna nagar
## 7 1 1 1 1
## Manikapir Manikapur Nagarpalika road Piprahwa Pokheral tole
## 1 5 2 1 1
## Pumdhi Pumdi vumdi Rajdevi tol Rajdevi tole Rampur
## 1 1 3 4 2
## Ranighat Ryale Patle Sajha tole santipur Sarboday tole
## 2 1 1 3 1
## Shivanagar Sivanagar Tarigau Tarigaun Tharu gau tol
## 1 3 1 1 2
## Valam
## 4
## [1] "Frequency table after encoding"
## mid2_child_villagename. Villagename
## 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658
## 1 1 3 2 1 7060 1 7 2 2 1 1 2 2 1 1 4 1
## 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
## 4 3 5 3 1 1 1 1 1 2 2 1 2 1 3 2 2 2
## 677 678 679 680 681
## 2 1 1 1 1
## [1] "Frequency table before encoding"
## mid2_child_settlement.
## Aadarsh tole Bahaya khola Basantpure bhalam
## 7060 2 2 2 1
## Bijeynagar chanautae Copan gunj Dadre Darahi tol
## 2 2 1 1 2
## dhaurali Gayatri tole Ghariwara Gopal chook Gopalgunj
## 1 1 2 1 2
## Gurung gau Himalay tole Hulaki tol Jayanagar kamere pani tol
## 1 1 1 2 1
## Kharsal tole Kulayen tol Maanpur Nagarpalika road Namunatol
## 1 1 2 2 1
## Pokheral tole Pothedarpurwa Pragtinagar Pumdikot Purba rampur
## 1 2 1 1 2
## Radha krishna Tol Radhakrisna Rajdevi Rajdevi tole Rameshorpurwa
## 2 1 5 2 4
## rammandir Ramwapur Ranighat Sajha tole santipur
## 2 5 2 1 3
## Sarbodai tole Shivanagar Swara Tangpasri Tharugau
## 1 1 1 1 2
## Vagawanpur
## 1
## [1] "Frequency table after encoding"
## mid2_child_settlement.
## 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
## 2 5 1 1 2 1 2 2 1 2 2 1 3 1 1 2 2 1
## 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
## 1 1 1 2 1 2 1 1 7060 1 1 2 2 5 2 2 2 1
## 152 153 154 155 156 157 158 159 160 161
## 2 1 2 1 1 1 1 2 4 1
# Focus on variables with a "Lowest Freq" of 10 or less.
mydata <- top_recode ("mid2_s3q3", break_point=80, missing=999999) # Topcode cases age 80 or older
## [1] "Frequency table before encoding"
## mid2_s3q3. Age in completed years at the time of survey:
## 0 1 2 3 4 5 6 7 8 9 10 11 12
## 23 35 66 99 133 131 162 179 203 174 189 169 215
## 13 14 15 16 17 18 19 20 21 22 23 24 25
## 189 225 202 146 118 160 86 91 44 57 57 50 107
## 26 27 28 29 30 31 32 33 34 35 36 37 38
## 83 75 77 64 149 89 108 77 66 182 160 82 120
## 39 40 41 42 43 44 45 46 47 48 49 50 51
## 60 175 73 82 34 27 101 71 36 36 29 71 46
## 52 53 54 55 56 57 58 59 60 61 62 63 64
## 32 13 20 63 43 15 27 23 54 37 26 10 15
## 65 66 67 68 69 70 71 72 73 74 75 76 77
## 56 30 16 16 13 49 17 22 15 6 21 5 5
## 78 79 80 81 82 83 84 85 87 88 89 90 91
## 4 4 6 5 4 4 5 5 4 2 1 3 1
## 92 95 96 98 100 594835 <NA>
## 1 2 1 2 2 1 947
## [1] "Frequency table after encoding"
## mid2_s3q3. Age in completed years at the time of survey:
## 0 1 2 3 4 5 6 7
## 23 35 66 99 133 131 162 179
## 8 9 10 11 12 13 14 15
## 203 174 189 169 215 189 225 202
## 16 17 18 19 20 21 22 23
## 146 118 160 86 91 44 57 57
## 24 25 26 27 28 29 30 31
## 50 107 83 75 77 64 149 89
## 32 33 34 35 36 37 38 39
## 108 77 66 182 160 82 120 60
## 40 41 42 43 44 45 46 47
## 175 73 82 34 27 101 71 36
## 48 49 50 51 52 53 54 55
## 36 29 71 46 32 13 20 63
## 56 57 58 59 60 61 62 63
## 43 15 27 23 54 37 26 10
## 64 65 66 67 68 69 70 71
## 15 56 30 16 16 13 49 17
## 72 73 74 75 76 77 78 79
## 22 15 6 21 5 5 4 4
## 80 or more <NA>
## 49 947
mydata <- top_recode ("mid2_s4q7", break_point=60, missing=999999) # Topcode cases with 60 or farther
## [1] "Frequency table before encoding"
## mid2_s4q7. How far is the school from home?
## 0 1 2 3 4 5 6 7 8 9 10 12 15 20 23 25 30 210
## 72 749 336 184 53 57 25 6 7 1 31 4 25 3 1 1 6 1
## 215 225 <NA>
## 1 1 5572
## [1] "Frequency table after encoding"
## mid2_s4q7. How far is the school from home?
## 0 1 2 3 4 5 6 7
## 72 749 336 184 53 57 25 6
## 8 9 10 12 15 20 23 25
## 7 1 31 4 25 3 1 1
## 30 60 or more <NA>
## 6 3 5572
mydata <- top_recode ("mid2_child_nhhmmbrs", break_point=10, missing=999999) # Topcode cases with 10 or more members
## [1] "Frequency table before encoding"
## mid2_child_nhhmmbrs.
## 2 3 4 5 6 7 9 10 <NA>
## 2 12 11 26 13 4 3 5 7060
## [1] "Frequency table after encoding"
## mid2_child_nhhmmbrs. 10
## 2 3 4 5 6 7 9 10 or more
## 2 12 11 26 13 4 3 5
## <NA>
## 7060
mydata <- top_recode ("mid2_s17q7", break_point=60, missing=999999) # Topcode cases with 60 or farther
## [1] "Frequency table before encoding"
## mid2_s17q7. How far is the school from home?
## 0 1 2 3 4 5 6 7 8 9 10 11 12 15 20 30 33 220
## 72 660 301 159 54 54 23 5 5 1 29 1 2 23 1 9 1 1
## <NA>
## 5735
## [1] "Frequency table after encoding"
## mid2_s17q7. How far is the school from home?
## 0 1 2 3 4 5 6 7
## 72 660 301 159 54 54 23 5
## 8 9 10 11 12 15 20 30
## 5 1 29 1 2 23 1 9
## 33 60 or more <NA>
## 1 1 5735
mydata <- top_recode ("mid2_s4q8", break_point=60, missing=999999) # Topcode cases with 60 or longer
## [1] "Frequency table before encoding"
## mid2_s4q8. How long does it take to get to this school?
## 0 1 2 3 4 5 6 7 8 10 12 15 16 17 18 20 25 28
## 1 19 28 14 3 360 5 6 5 527 7 392 1 1 6 303 51 6
## 30 35 40 45 50 60 70 90 120 <NA>
## 333 10 6 37 1 86 1 5 2 4920
## [1] "Frequency table after encoding"
## mid2_s4q8. How long does it take to get to this school?
## 0 1 2 3 4 5 6 7
## 1 19 28 14 3 360 5 6
## 8 10 12 15 16 17 18 20
## 5 527 7 392 1 1 6 303
## 25 28 30 35 40 45 50 60 or more
## 51 6 333 10 6 37 1 94
## <NA>
## 4920
# !!!Include relevant variables in list below
indirect_PII <- c("mid2_occup0",
"mid2_s5q6c",
"mid2_occup1",
"mid2_s19q4c",
"mid2_ind0",
"mid2_s5q6_2c",
"mid2_ind1",
"mid2_s19q4bc",
"mid2_nhhmmbrs",
"mid2_s8q0",
"mid2_s10q6b",
"mid2_s11q2",
"mid2_s11q3",
"mid2_s11q4",
"mid2_s11q5",
"mid2_s11q6",
"mid2_s11q7",
"mid2_s11q8",
"mid2_s11q9",
"mid2_s13q1_1",
"mid2_s13q1_2",
"mid2_s13q1_3",
"mid2_s13q1_4",
"mid2_s13q1_5",
"mid2_s13q1_6",
"mid2_s13q1_7",
"mid2_s13q1_8",
"mid2_s13q1_9",
"mid2_s13q1_10",
"mid2_s13q1_11",
"mid2_s13q1_12",
"mid2_s13q1_13",
"mid2_s13q1_14",
"mid2_s13q1_96",
"mid2_s3q2",
"mid2_s3q2a",
"mid2_s3q3",
"mid2_phone",
"mid2_s3q4",
"mid2_s3q5_1",
"mid2_onlychild",
"mid2_s3q6",
"mid2_s3q7",
"mid2_s3q8",
"mid2_s3q9a",
"mid2_s3q9b",
"mid2_s3q9c",
"mid2_s3q9d",
"mid2_s3q9e",
"mid2_s3q10",
"mid2_s4q1",
"mid2_s4q2",
"mid2_s4q3",
"mid2_s4q3_1",
"mid2_s4q4",
"mid2_s4q6_1",
"mid2_s4q6_2",
"mid2_s4q6_5",
"mid2_s4q6_9",
"mid2_s4q7",
"mid2_s4q8",
"mid2_s4q9",
"mid2_s4q9_1",
"mid2_s4q9_2",
"mid2_s4q9_3",
"mid2_s4q9_4",
"mid2_s4q9_5",
"mid2_s4q9_6",
"mid2_s4q9_7",
"mid2_s4q9_8",
"mid2_s4q9_96",
"mid2_s5q1",
"mid2_s5q1_1",
"mid2_s5q1_2",
"mid2_s5q1_3",
"mid2_s5q1_4",
"mid2_s5q1_5",
"mid2_s5q1_6",
"mid2_s5q1_7",
"mid2_s5q1_8",
"mid2_s5q1_9",
"mid2_s5q2a",
"mid2_s5q2b",
"mid2_s5q2c",
"mid2_s5q2d",
"mid2_s5q2e",
"mid2_s5q2f",
"mid2_s5q2g",
"mid2_s5q2h",
"mid2_s5q3",
"mid2_s5q4a",
"mid2_s5q4b",
"mid2_s5q4c",
"mid2_s5q4d",
"mid2_s5q4e",
"mid2_s5q4f",
"mid2_s5q4g",
"mid2_s5q4h",
"mid2_s5q4i",
"mid2_s5q5",
"mid2_s5q6a",
"mid2_s5q7",
"mid2_s5q8",
"mid2_s5q9",
"mid2_s5q11",
"mid2_s5q12",
"mid2_s5q15",
"mid2_s5q16",
"mid2_s5q18",
"mid2_s6q2",
"mid2_s6q7",
"mid2_s6q8",
"mid2_s16q3",
"mid2_s17q1",
"mid2_s17q2",
"mid2_s17q3",
"mid2_s17q4",
"mid2_s17q6_1",
"mid2_s17q6_2",
"mid2_s17q6_5",
"mid2_s17q6_9",
"mid2_s17q6_96",
"mid2_s17q6_98",
"mid2_s17q6_99",
"mid2_s17q7",
"mid2_s17q8",
"mid2_s17q8_1",
"mid2_s17q8_2",
"mid2_s17q8_3",
"mid2_s17q8_4",
"mid2_s17q8_5",
"mid2_s17q8_6",
"mid2_s17q8_7",
"mid2_s17q8_8",
"mid2_s18q1_1",
"mid2_s18q1_2",
"mid2_s18q1_3",
"mid2_s18q1_4",
"mid2_s18q1_5",
"mid2_s18q1_6",
"mid2_s18q1_7",
"mid2_s18q1_8",
"mid2_s18q1_9",
"mid2_s18q2a",
"mid2_s18q2b",
"mid2_s18q2c",
"mid2_s18q2d",
"mid2_s18q2e",
"mid2_s18q2f",
"mid2_s18q2g",
"mid2_s18q2h",
"mid2_s18q3_1",
"mid2_s18q3_2",
"mid2_s18q3_3",
"mid2_s18q3_4",
"mid2_s18q3_5",
"mid2_s18q3_96",
"mid2_s18q4",
"mid2_s19q1",
"mid2_s19q2a",
"mid2_s19q2b",
"mid2_s19q2c",
"mid2_s19q2d",
"mid2_s19q2e",
"mid2_s19q2f",
"mid2_s19q2g",
"mid2_s19q2h",
"mid2_s19q2i",
"mid2_s19q3",
"mid2_s19q4a",
"mid2_s19q5",
"mid2_s19q6",
"mid2_s19q7",
"mid2_s19q10_2",
"mid2_s19q10_3",
"mid2_s19q10_6",
"mid2_s19q10_9",
"mid2_s19q10_12",
"mid2_s19q12",
"mid2_s19q13",
"mid2_s19q14",
"mid2_s20q2",
"mid2_s20q4",
"mid2_s20q5",
"mid2_s20q7",
"mid2_s20q8",
"mid2_child_nhhmmbrs",
"mid2_numhhmbrs",
"mid2_female",
"mid2_ppi1",
"mid2_ppi2",
"mid2_ppi3",
"mid2_ppi4",
"mid2_ppi5",
"mid2_ppi6",
"mid2_ppi7",
"mid2_ppi8",
"mid2_ppi9",
"mid2_ppi10",
"mid2_CL_P",
"mid2_CL_C",
"mid2_CLC5_11",
"mid2_CLC12_13",
"mid2_CLC14_15",
"mid2_CLP5_11",
"mid2_CLP12_13",
"mid2_CLP14_15")
capture_tables (indirect_PII)
# Recode those with very specific values
# Removed, as verbatim responses are partially or entirely in Nepali.
dropvars <- c("mid2_occup0", "mid2_occup1", "mid2_ind0", "mid2_ind1")
mydata <- mydata[!names(mydata) %in% dropvars]
# Top code household composition variables with large and unusual numbers
mydata <- top_recode ("mid2_nhhmmbrs", break_point=10, missing=c(999999)) # Topcode cases with 10 or more members
## [1] "Frequency table before encoding"
## mid2_nhhmmbrs.
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## 9 148 738 1463 1512 1148 649 538 237 196 79 160 81 1 96 41 26 14
## [1] "Frequency table after encoding"
## mid2_nhhmmbrs. 10
## 1 2 3 4 5 6 7 8
## 9 148 738 1463 1512 1148 649 538
## 9 10 or more
## 237 694
mydata <- top_recode ("mid2_numhhmbrs", break_point=10, missing=c(999999)) # Topcode cases with 10 or more members
## [1] "Frequency table before encoding"
## mid2_numhhmbrs.
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## 239 42 465 1164 1450 1128 735 520 333 360 209 144 78 70 45 16 51 36
## 23 28
## 23 28
## [1] "Frequency table after encoding"
## mid2_numhhmbrs. 10
## 1 2 3 4 5 6 7 8
## 239 42 465 1164 1450 1128 735 520
## 9 10 or more
## 333 1060
# Based on dictionary inspection, select variables for creating sdcMicro object
# See: https://sdcpractice.readthedocs.io/en/latest/anon_methods.html
# All variable names should correspond to the names in the data file
# selected categorical key variables: gender, occupation/education and age
mydata$sex <- mydata$mid2_s3q2
mydata$sex [is.na(mydata$sex)] <- mydata$mid2_s3q2a[is.na(mydata$sex)]
selectedKeyVars = c('sex', 'mid2_s3q8', 'mid2_s3q3') ##!!! Replace with candidate categorical demo vars
# weight variable
# !!! No weight
# selectedWeightVar = c('projwt') ##!!! Replace with weight var
# household id variable (cluster)
selectedHouseholdID = c('hhid')
# creating the sdcMicro object with the assigned variables
sdcInitial <- createSdcObj(dat = mydata,
keyVars = selectedKeyVars,
hhId = selectedHouseholdID)
sdcInitial
## The input dataset consists of 7136 rows and 580 variables.
## --> Categorical key variables: sex, mid2_s3q8, mid2_s3q3
## --> Cluster/Household-Id variable: hhid
## ----------------------------------------------------------------------
## Information on categorical key variables:
##
## Reported is the number, mean size and size of the smallest category >0 for recoded variables.
## In parenthesis, the same statistics are shown for the unmodified data.
## Note: NA (missings) are counted as seperate categories!
## Key Variable Number of categories Mean size Size of smallest (>0)
## sex 3 (3) 3093.000 (3093.000) 2975 (2975)
## mid2_s3q8 10 (10) 647.667 (647.667) 11 (11)
## mid2_s3q3 82 (82) 76.407 (76.407) 4 (4)
## ----------------------------------------------------------------------
## Infos on 2/3-Anonymity:
##
## Number of observations violating
## - 2-anonymity: 164 (2.298%)
## - 3-anonymity: 360 (5.045%)
## - 5-anonymity: 790 (11.071%)
##
## ----------------------------------------------------------------------
Show values of key variable of records that violate k-anonymity
notAnon <- sdcInitial@risk$individual[,2] < 2 # for 2-anonymity
as.data.frame(mydata[notAnon,selectedKeyVars])
## sex mid2_s3q8 mid2_s3q3
## 1 1 6 32
## 2 0 2 7
## 3 0 0 79
## 4 0 6 7
## 5 0 4 65
## 6 1 4 63
## 7 1 98 37
## 8 0 5 19
## 9 1 99 42
## 10 1 6 25
## 11 0 5 69
## 12 1 5 31
## 13 0 3 59
## 14 0 1 39
## 15 1 2 43
## 16 1 1 79
## 17 0 0 59
## 18 1 3 12
## 19 0 1 52
## 20 1 1 75
## 21 0 3 62
## 22 0 5 21
## 23 1 6 56
## 24 1 0 8
## 25 0 4 14
## 26 1 5 29
## 27 1 98 71
## 28 1 2 65
## 29 0 6 76
## 30 1 0 78
## 31 0 5 18
## 32 0 6 45
## 33 1 6 55
## 34 1 4 44
## 35 0 6 54
## 36 0 4 63
## 37 1 0 13
## 38 1 3 49
## 39 0 0 22
## 40 1 6 11
## 41 1 2 59
## 42 0 5 48
## 43 0 99 41
## 44 1 3 74
## 45 0 5 66
## 46 0 5 71
## 47 1 3 55
## 48 1 6 30
## 49 0 0 15
## 50 1 99 23
## 51 0 98 80
## 52 1 98 6
## 53 1 3 60
## 54 0 5 53
## 55 1 1 73
## 56 0 4 66
## 57 0 4 61
## 58 0 98 31
## 59 0 0 63
## 60 0 5 26
## 61 0 4 48
## 62 0 98 41
## 63 1 6 14
## 64 1 6 12
## 65 0 3 79
## 66 1 3 44
## 67 0 3 63
## 68 1 1 54
## 69 0 0 49
## 70 1 98 65
## 71 1 3 11
## 72 0 98 64
## 73 0 1 72
## 74 1 2 57
## 75 1 5 23
## 76 1 6 41
## 77 1 5 33
## 78 0 99 45
## 79 1 99 8
## 80 0 98 60
## 81 1 1 63
## 82 0 1 67
## 83 0 4 72
## 84 1 2 47
## 85 1 98 39
## 86 1 1 72
## 87 1 6 73
## 88 0 6 12
## 89 1 5 22
## 90 0 1 63
## 91 1 6 51
## 92 1 1 44
## 93 1 98 24
## 94 1 99 34
## 95 0 2 9
## 96 1 2 54
## 97 1 6 60
## 98 1 0 74
## 99 1 98 72
## 100 0 4 47
## 101 1 98 17
## 102 1 98 36
## 103 0 1 71
## 104 1 1 53
## 105 1 4 59
## 106 0 5 58
## 107 1 2 77
## 108 1 99 49
## 109 0 98 70
## 110 1 4 57
## 111 1 99 11
## 112 1 99 66
## 113 1 6 40
## 114 0 98 47
## 115 0 2 53
## 116 1 5 34
## 117 0 5 56
## 118 0 1 75
## 119 1 6 17
## 120 1 99 37
## 121 1 5 68
## 122 0 3 61
## 123 1 0 79
## 124 0 4 74
## 125 0 3 57
## 126 1 98 26
## 127 1 6 65
## 128 0 3 69
## 129 1 1 66
## 130 0 0 76
## 131 1 5 41
## 132 1 6 35
## 133 0 4 73
## 134 0 4 59
## 135 0 2 71
## 136 1 5 58
## 137 0 2 80
## 138 1 98 61
## 139 1 5 45
## 140 1 0 21
## 141 0 0 23
## 142 0 4 58
## 143 1 2 53
## 144 1 4 47
## 145 1 6 22
## 146 1 1 62
## 147 0 0 78
## 148 1 3 62
## 149 0 6 32
## 150 0 1 48
## 151 0 3 52
## 152 1 98 64
## 153 0 5 52
## 154 1 4 48
## 155 0 1 56
## 156 0 3 64
## 157 1 2 58
## 158 0 0 8
## 159 1 99 38
## 160 0 3 31
## 161 0 2 72
## 162 0 6 51
## 163 1 6 42
## 164 1 5 32
sdcFinal <- localSuppression(sdcInitial)
# Recombining anonymized variables (exclude children, as critical for analysis)
extractManipData(sdcFinal)[notAnon,selectedKeyVars] # manipulated variables HH
## Warning in if (cc != class(v_p)) {: the condition has length > 1 and only the first element
## will be used
## Warning in if (cc != class(v_p)) {: the condition has length > 1 and only the first element
## will be used
## Warning in if (cc != class(v_p)) {: the condition has length > 1 and only the first element
## will be used
## sex mid2_s3q8 mid2_s3q3
## 11 1 6 NA
## 97 0 2 NA
## 115 0 0 NA
## 141 0 6 NA
## 149 0 4 NA
## 157 1 4 NA
## 307 1 98 NA
## 365 0 5 NA
## 543 1 99 NA
## 651 1 6 NA
## 687 0 5 NA
## 764 1 5 NA
## 790 0 3 NA
## 825 0 1 NA
## 848 1 2 NA
## 853 1 1 NA
## 859 0 0 NA
## 867 1 3 NA
## 889 0 1 NA
## 970 1 1 NA
## 1004 0 3 NA
## 1012 0 5 NA
## 1021 1 6 NA
## 1041 1 0 NA
## 1120 0 4 NA
## 1196 1 5 NA
## 1222 1 98 NA
## 1230 1 2 NA
## 1255 0 6 NA
## 1256 1 0 NA
## 1442 0 5 NA
## 1464 0 6 NA
## 1481 1 6 NA
## 1482 1 4 NA
## 1685 0 6 NA
## 1721 0 4 NA
## 1739 1 0 NA
## 1779 1 3 NA
## 1849 0 0 NA
## 1988 1 6 NA
## 1995 1 2 NA
## 2064 0 5 NA
## 2078 0 99 NA
## 2196 1 3 NA
## 2198 0 5 NA
## 2219 0 5 NA
## 2268 1 3 NA
## 2284 1 6 NA
## 2439 0 0 NA
## 2482 1 99 NA
## 2487 0 98 NA
## 2506 1 98 NA
## 2569 1 3 NA
## 2609 0 5 NA
## 2649 1 1 NA
## 2667 0 4 NA
## 2725 0 4 NA
## 2780 0 98 NA
## 2803 0 0 NA
## 2970 0 5 NA
## 2981 0 4 NA
## 2999 0 98 NA
## 3012 1 6 NA
## 3016 1 6 NA
## 3074 0 3 NA
## 3092 1 3 NA
## 3102 0 3 NA
## 3138 1 1 NA
## 3164 0 0 NA
## 3214 1 98 NA
## 3259 1 3 NA
## 3297 0 98 NA
## 3384 0 1 NA
## 3444 1 2 NA
## 3498 1 5 NA
## 3558 1 6 NA
## 3621 1 5 NA
## 3650 0 99 NA
## 3670 1 99 NA
## 3674 0 98 NA
## 3767 1 1 NA
## 3775 0 1 NA
## 3785 0 4 NA
## 3886 1 2 NA
## 3907 1 98 NA
## 3915 1 1 NA
## 3917 1 6 NA
## 3950 0 6 NA
## 3974 1 5 NA
## 4106 0 1 NA
## 4150 1 6 NA
## 4216 1 1 NA
## 4250 1 98 NA
## 4296 1 99 NA
## 4298 0 2 NA
## 4395 1 2 NA
## 4427 1 6 NA
## 4449 1 0 NA
## 4517 1 98 NA
## 4550 0 4 NA
## 4552 1 98 NA
## 4553 1 98 NA
## 4709 0 1 NA
## 4756 1 1 NA
## 4825 1 4 NA
## 4826 0 5 NA
## 4829 1 2 NA
## 4921 1 99 NA
## 4923 0 98 NA
## 4926 1 4 NA
## 4940 1 99 NA
## 4960 1 99 NA
## 5061 1 6 NA
## 5066 0 98 NA
## 5250 0 2 NA
## 5368 1 5 NA
## 5393 0 5 NA
## 5395 0 1 NA
## 5435 1 6 NA
## 5438 1 99 NA
## 5498 1 5 NA
## 5510 0 3 NA
## 5571 1 0 NA
## 5652 0 4 NA
## 5731 0 3 NA
## 5746 1 98 NA
## 5806 1 6 NA
## 5807 0 3 NA
## 5847 1 1 NA
## 5871 0 0 NA
## 5876 1 5 NA
## 5893 1 6 NA
## 5952 0 4 NA
## 5985 0 4 NA
## 5989 0 2 NA
## 6001 1 5 NA
## 6005 0 2 NA
## 6050 1 98 NA
## 6091 1 5 NA
## 6119 1 0 NA
## 6123 0 0 NA
## 6168 0 4 NA
## 6236 1 2 NA
## 6305 1 4 NA
## 6377 1 6 NA
## 6423 1 1 NA
## 6427 0 0 NA
## 6460 1 3 NA
## 6538 0 6 NA
## 6541 0 1 NA
## 6547 0 3 NA
## 6571 1 98 NA
## 6573 0 5 NA
## 6723 1 4 NA
## 6725 0 1 NA
## 6751 0 3 NA
## 6752 1 2 NA
## 6768 0 0 NA
## 6781 1 99 NA
## 6888 0 3 NA
## 6987 0 2 NA
## 7112 0 6 NA
## 7114 1 6 NA
## 7118 1 5 NA
mydata [notAnon & mydata$mid2_s3q3 >17,"mid2_s3q3"] <- NA
#Check that 2-anonimity is now maintained
createSdcObj(dat = mydata, keyVars = selectedKeyVars, hhId = selectedHouseholdID)
## The input dataset consists of 7136 rows and 580 variables.
## --> Categorical key variables: sex, mid2_s3q8, mid2_s3q3
## --> Cluster/Household-Id variable: hhid
## ----------------------------------------------------------------------
## Information on categorical key variables:
##
## Reported is the number, mean size and size of the smallest category >0 for recoded variables.
## In parenthesis, the same statistics are shown for the unmodified data.
## Note: NA (missings) are counted as seperate categories!
## Key Variable Number of categories Mean size Size of smallest (>0)
## sex 3 (3) 3093.000 (3093.000) 2975 (2975)
## mid2_s3q8 10 (10) 647.667 (647.667) 11 (11)
## mid2_s3q3 81 (81) 75.550 (75.550) 2 (2)
## ----------------------------------------------------------------------
## Infos on 2/3-Anonymity:
##
## Number of observations violating
## - 2-anonymity: 0 (0.000%)
## - 3-anonymity: 0 (0.000%)
## - 5-anonymity: 0 (0.000%)
##
## ----------------------------------------------------------------------
mydata <- mydata[!names(mydata) %in% "sex"]
# !!! Identify open-end variables here:
open_ends <- c("mid2_s9q1_1other",
"mid2_s9q2_2other",
"mid2_s9q2_1other",
"mid2_s9q1_2other",
"mid2_s9q5other",
"mid2_s9q6other",
"mid2_s10q3other",
"mid2_s10q5other",
"mid2_s10q8other",
"mid2_s10q10other",
"mid2_s11q3other",
"mid2_s11q6other",
"mid2_s13q1other",
"mid2_s3q1other",
"mid2_s3q5other",
"mid2_s4q6other",
"mid2_s4q9other",
"mid2_s4q11other",
"mid2_s5q6",
"mid2_s5q6_2",
"mid2_s5q14other",
"mid2_s17q6other",
"mid2_s17q9other",
"mid2_s18q3other",
"mid2_s19q4",
"mid2_s19q4b",
"mid2_s6q8other",
"mid2_s17q8other")
report_open (list_open_ends = open_ends)
# Review "verbatims.csv". Identify variables to be deleted or redacted and their row number
mydata <- mydata[!names(mydata) %in% open_ends] # SDC risk could not be ascertained as all verbatims are partially or completely in Nepali.
# !!! No GPS data.
Adds "_PU" (Public Use) to the end of the name
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)