Rename column names of data exported from an ODK Aggregate Server or from ODK Briefcase into more usable and human readable variable names.
Source:R/renameODK.R
renameODK.Rd
Rename column names of data exported from an ODK Aggregate Server or from ODK Briefcase into more usable and human readable variable names.
Usage
renameODK(data, sep = c(".", "-"))
Examples
# Rename sampleData1 dataset to remove '.' from variable names
names(sampleData1)
#> [1] "admin.admin1.adm1" "admin.admin1.adm2" "admin.ename"
#> [4] "admin.enameA" "admin.admin2.adm3" "admin.admin2.adm4"
#> [7] "location.loc1" "location.loc1a" "location.loc2"
#> [10] "location.loc3" "location.loc4" "hh1"
#> [13] "hh2" "wcount_count" "KEY"
#> [16] "PARENT_KEY"
renameODK(sampleData1)
#> adm1 adm2 ename enameA adm3 adm4 loc1
#> 1 2016-12-24 4 Eman Abdelaleem Zakaria _____ ___ ______ 4 6 6
#> 2 2016-12-24 7 Hafsa Ali Mohamed ____ ___ ____ 4 4 1
#> 3 2016-12-24 5 Fatima Abdallah _____ ___ ____ 3 6 6
#> 4 2016-12-24 1 Amani Elkheir _____ _____ 4 5 2
#> 5 2016-12-24 20 Zahra Younis ____ ____ 4 7 17
#> 6 2016-12-24 13 Mahasin Mohamed Elhassan _____ ____ 4 3 10
#> 7 2016-12-24 11 Khadija Adam _____ ___ 4 3 10
#> 8 2016-12-24 18 Thuraya Mahmoud ____ ____ 4 6 6
#> 9 2016-12-24 5 Fatima Abdallah _____ ___ ____ 4 6 6
#> 10 2016-12-24 7 Hafsa Ali Mohamed ____ ___ ____ 4 4 1
#> 11 2016-12-24 19 Thuraya Osman ____ _____ 4 5 2
#> 12 2016-12-24 7 Hafsa Ali Mohamed ____ ___ ____ 4 4 1
#> 13 2016-12-24 13 Mahasin Mohamed Elhassan _____ ____ 4 3 10
#> 14 2016-12-24 1 Amani Elkheir _____ _____ 4 5 2
#> 15 2016-12-24 18 Thuraya Mahmoud ____ ____ 4 6 6
#> 16 2016-12-24 20 Zahra Younis ____ ____ 4 7 17
#> 17 2016-12-24 5 Fatima Abdallah _____ ___ ____ 3 6 6
#> 18 2016-12-24 11 Khadija Adam _____ ___ 4 3 10
#> 19 2016-12-24 19 Thuraya Osman ____ _____ 4 5 2
#> 20 2016-12-24 20 Zahra Younis ____ ____ 4 7 17
#> 21 2016-12-24 4 Eman Abdelaleem Zakaria _____ ___ ______ 4 6 6
#> 22 2016-12-24 2 Amira Abdeen _____ ______ 4 7 17
#> 23 2016-12-24 5 Fatima Abdallah _____ ___ ____ 4 6 6
#> 24 2016-12-24 17 Sabah Salih Ibrahim ____ ____ 4 5 2
#> 25 2016-12-24 6 Fatima Alamin _____ ______ 4 3 10
#> 26 2016-12-24 7 Hafsa Ali Mohamed ____ ___ ____ 4 4 1
#> 27 2016-12-24 18 Thuraya Mahmoud ____ ____ 4 6 6
#> 28 2016-12-24 9 Hayat Mohamed Idris ____ ____ 4 1 3
#> 29 2016-12-24 13 Mahasin Mohamed Elhassan _____ ____ 4 3 10
#> 30 2016-12-24 1 Amani Elkheir _____ _____ 4 5 2
#> 31 2016-12-24 15 Omaima Homeida _____ _____ 4 1 3
#> 32 2016-12-24 14 Manihil Fadl Alsid _____ ___ _____ 4 4 1
#> 33 2016-12-24 7 Hafsa Ali Mohamed ____ ___ ____ 4 4 1
#> 34 2016-12-24 2 Amira Abdeen _____ ______ 4 7 17
#> 35 2016-12-24 11 Khadija Adam _____ ___ 4 3 10
#> 36 2016-12-24 5 Fatima Abdallah _____ ___ ____ 4 6 6
#> 37 2016-12-24 17 Sabah Salih Ibrahim ____ ____ 4 1 3
#> 38 2016-12-24 6 Fatima Alamin _____ ______ 4 3 10
#> 39 2016-12-24 4 Eman Abdelaleem Zakaria _____ ___ ______ 4 6 6
#> 40 2016-12-24 18 Thuraya Mahmoud ____ ____ 4 6 6
#> 41 2016-12-24 9 Hayat Mohamed Idris ____ ____ 4 1 2
#> 42 2016-12-24 13 Mahasin Mohamed Elhassan _____ ____ 4 3 10
#> 43 2016-12-24 3 Awadia Mohamed Ali _____ ____ 4 4 1
#> 44 2016-12-24 5 Fatima Abdallah _____ ___ ____ 4 6 6
#> 45 2016-12-24 7 Hafsa Ali Mohamed ____ ___ ____ 4 4 1
#> 46 2016-12-24 18 Thuraya Mahmoud ____ ____ 4 6 6
#> 47 2016-12-24 5 Fatima Abdallah _____ ___ ____ 4 6 6
#> 48 2016-12-24 20 Zahra Younis ____ ____ 4 7 17
#> 49 2016-12-24 2 Amira Abdeen _____ ______ 4 7 17
#> 50 2016-12-24 9 Hayat Mohamed Idris ____ ____ 4 1 2
#> loc1a loc2 loc3
#> 1 2 300
#> 2 2 1500
#> 3 2 300
#> 4 2 1000
#> 5 2 1000
#> 6 2 150
#> 7 2 150
#> 8 2 300
#> 9 2 300
#> 10 2 1500
#> 11 2 1000
#> 12 2 1500
#> 13 2 150
#> 14 2 1000
#> 15 2 300
#> 16 2 1000
#> 17 2 300
#> 18 2 150
#> 19 2 1000
#> 20 2 1000
#> 21 2 300
#> 22 2 1000
#> 23 2 300
#> 24 2 1000
#> 25 2 150
#> 26 2 1500
#> 27 2 300
#> 28 2 100
#> 29 2 150
#> 30 2 1000
#> 31 2 100
#> 32 2 1500
#> 33 2 1500
#> 34 2 1000
#> 35 2 150
#> 36 2 300
#> 37 2 100
#> 38 2 150
#> 39 2 300
#> 40 2 300
#> 41 2 100
#> 42 2 150
#> 43 2 1500
#> 44 2 300
#> 45 2 1500
#> 46 2 300
#> 47 2 300
#> 48 2 1000
#> 49 2 1000
#> 50 2 100
#> loc4 hh1 hh2
#> 1 15.340707055739859 36.409332161777634 489.62804045528173 20.0 10 1
#> 2 15.243085888579019 35.50734621989882 470.2089592535049 25.0 2 1
#> 3 18 1
#> 4 14.863367945089205 35.866666603118375 -1.9034378901124 15.0 5 1
#> 5 15.468007832681407 36.43122575900205 521.5972869871184 25.0 11 1
#> 6 15.858674407154577 36.37231720853207 454.6278015691787 10.0 6 1
#> 7 7 1
#> 8 15.344821969653859 36.4123056904053 524.6815485022962 20.0 19 1
#> 9 15.342416367468351 36.409081857962754 509.3362386887893 15.0 19 1
#> 10 15.242720015920215 35.50733519201448 461.8070472544059 10.0 3 1
#> 11 14.863197175573642 35.86928686765128 462.4303112337366 10.0 5 1
#> 12 15.242760667735546 35.507351704810645 468.1484348261729 20.0 4 1
#> 13 7 1
#> 14 6 1
#> 15 15.344836542984442 36.412303807482466 528.715526827611 25.0 20 1
#> 16 12 1
#> 17 20 1
#> 18 15.859804355349041 36.3697683675118 467.4077677382156 10.0 8 1
#> 19 14.86303281506242 35.86851605079117 485.36729476600885 15.0 6 1
#> 20 13 1
#> 21 15.340626004927747 36.409704627473516 531.3647508798167 15.0 11 1
#> 22 15.468108546033292 36.43084176907657 529.8765007127076 20.0 10 1
#> 23 15.341934954061003 36.40920065801615 509.6119866305962 20.0 21 1
#> 24 6 1
#> 25 15.857047611120107 36.367080908743965 457.56518397387117 25.0 10 1
#> 26 15.242564793065485 35.507391095599594 459.71703636739403 15.0 5 1
#> 27 15.345046529712212 36.412365115620794 529.1299370490015 10.0 21 1
#> 28 15.508623605231321 35.71921247885054 393.2120068129152 10.0 7 1
#> 29 8 1
#> 30 14.863073715960105 35.868534599770236 475.1144825257361 25.0 7 1
#> 31 15.507955124315897 35.71994656880656 435.78340286947787 15.0 1 1
#> 32 15.243935478477816 35.5072483748536 462.23733238969 20.0 2 1
#> 33 15.243544853526092 35.504358697667676 318.2708964664489 10.0 6 1
#> 34 15.468348778718005 36.430295749140896 527.3553353380412 25.0 11 1
#> 35 15.858663032550746 36.37233865660788 453.68353387061507 15.0 9 1
#> 36 15.34195942957224 36.40936281884173 542.9970574751496 20.0 22 1
#> 37 15.50791103507599 35.71998905828642 443.707229337655 15.0 1 1
#> 38 11 1
#> 39 15.340625957958748 36.409617272319956 522.9894889993593 15.0 12 1
#> 40 15.345026304693446 36.411030820483106 511.9512688117102 15.0 22 1
#> 41 15.507898530115408 35.72003764021008 437.78598945215344 10.0 2 1
#> 42 9 1
#> 43 15.243843041379714 35.50728506878729 464.1237193001434 20.0 1 1
#> 44 23 1
#> 45 15.241833111246876 35.50801737078307 461.0185168450698 15.0 7 1
#> 46 23 1
#> 47 15.34193913638263 36.40920103182395 515.2498174784705 15.0 24 1
#> 48 15.468200337263658 36.43041438343925 517.0020088292658 20.0 13 1
#> 49 15.4686049946019 36.429610500645374 512.2657940238714 20.0 12 1
#> 50 3 1
#> wcount_count KEY PARENT_KEY
#> 1 1 1 -1
#> 2 1 2 -1
#> 3 1 3 -1
#> 4 1 4 -1
#> 5 1 5 -1
#> 6 1 6 -1
#> 7 1 7 -1
#> 8 1 8 -1
#> 9 1 9 -1
#> 10 1 10 -1
#> 11 1 11 -1
#> 12 1 12 -1
#> 13 1 13 -1
#> 14 1 14 -1
#> 15 1 15 -1
#> 16 1 16 -1
#> 17 1 17 -1
#> 18 1 18 -1
#> 19 1 19 -1
#> 20 1 20 -1
#> 21 1 21 -1
#> 22 1 22 -1
#> 23 1 23 -1
#> 24 1 24 -1
#> 25 1 25 -1
#> 26 1 26 -1
#> 27 1 27 -1
#> 28 1 28 -1
#> 29 1 29 -1
#> 30 1 30 -1
#> 31 1 31 -1
#> 32 1 32 -1
#> 33 1 33 -1
#> 34 1 34 -1
#> 35 1 35 -1
#> 36 1 36 -1
#> 37 1 37 -1
#> 38 1 38 -1
#> 39 1 39 -1
#> 40 1 40 -1
#> 41 1 41 -1
#> 42 1 42 -1
#> 43 1 43 -1
#> 44 1 44 -1
#> 45 1 45 -1
#> 46 1 46 -1
#> 47 1 47 -1
#> 48 1 48 -1
#> 49 1 49 -1
#> 50 1 50 -1
names(sampleData1)
#> [1] "admin.admin1.adm1" "admin.admin1.adm2" "admin.ename"
#> [4] "admin.enameA" "admin.admin2.adm3" "admin.admin2.adm4"
#> [7] "location.loc1" "location.loc1a" "location.loc2"
#> [10] "location.loc3" "location.loc4" "hh1"
#> [13] "hh2" "wcount_count" "KEY"
#> [16] "PARENT_KEY"
# Rename sampleData2 dataset
names(sampleData2)
#> [1] "wcount.wdata.women.wage" "wcount.wdata.women.wmarried"
#> [3] "wcount.wdata.women.wpregnant" "wcount.wdata.women.wedu1"
#> [5] "wcount.wdata.women.wedu2" "wcount.wdata.women.wanthro"
#> [7] "wcount.wdata.women.screening" "wcount.wdata.wash.ws1"
#> [9] "wcount.wdata.wash.ws2" "wcount.wdata.wash.ws3"
#> [11] "wcount.wdata.wash.ws4" "wcount.wdata.wash.ws5"
#> [13] "wcount.wdata.wash.ws6" "wcount.wdata.wash.ws7"
#> [15] "KEY" "PARENT_KEY"
renameODK(sampleData2)
#> wage wmarried wpregnant wedu1 wedu2 wanthro screening ws1 ws2 ws3 ws4 ws5
#> 1 20 1 2 3 1 270 2 13 2 12 NA NA
#> 2 35 1 2 0 9 235 2 9 2 7 1 1 2
#> 3 16 2 2 5 1 174 2 12 7 12 NA NA
#> 4 30 1 2 0 9 269 2 12 7 12 NA NA
#> 5 18 2 2 8 2 225 2 13 7 12 NA NA
#> 6 25 1 2 3 1 128 2 8 7 12 NA NA
#> 7 27 1 2 0 9 268 2 8 7 12 NA NA
#> 8 48 1 2 0 9 210 2 12 3 12 NA NA
#> 9 18 1 1 0 1 162 2 12 7 12 NA NA
#> 10 16 2 2 3 1 211 2 9 2 3 7 1 1 2
#> 11 46 1 2 0 9 331 2 13 2 12 NA NA
#> 12 38 1 2 0 9 335 2 9 2 3 7 1 1 2
#> 13 22 1 2 4 1 227 2 8 1 12 NA NA
#> 14 28 1 2 0 9 258 2 12 7 12 NA NA
#> 15 18 1 2 4 1 196 2 12 3 12 NA NA
#> 16 NA NA NA NA NA NA NA NA NA NA NA
#> 17 16 1 2 0 9 181 2 12 7 12 NA NA
#> 18 15 1 2 0 9 225 2 8 7 12 NA NA
#> 19 16 1 1 5 1 220 2 13 4 12 NA NA
#> 20 25 1 2 0 9 260 2 13 7 12 NA NA
#> 21 35 1 2 3 1 243 2 13 3 12 NA NA
#> 22 18 2 2 11 3 272 2 13 7 2 2 2
#> 23 30 1 1 0 9 189 2 12 7 12 NA NA
#> 24 33 1 2 3 1 240 1 13 1 1 1 1
#> 25 18 2 2 1 1 235 2 11 7 12 NA NA
#> 26 25 1 2 0 9 245 2 9 2 3 1 1 1
#> 27 25 1 2 0 9 287 2 12 3 12 NA NA
#> 28 46 1 2 0 9 194 2 9 7 12 NA NA
#> 29 40 1 2 0 9 233 1 8 7 12 NA NA
#> 30 16 2 2 7 1 179 2 12 7 2 2 2
#> 31 19 1 2 0 9 182 1 9 7 12 NA NA
#> 32 23 1 2 0 9 134 2 9 7 10 1 2
#> 33 31 1 2 0 9 248 2 9 2 3 2 1 1
#> 34 30 1 2 3 1 283 2 13 7 12 NA NA
#> 35 25 1 1 0 9 245 2 8 7 12 NA NA
#> 36 17 2 2 4 1 182 2 12 7 12 NA NA
#> 37 30 1 2 0 9 220 2 9 7 12 NA NA
#> 38 36 1 2 1 1 235 2 10 7 12 NA NA
#> 39 27 1 2 2 9 205 2 13 2 12 NA NA
#> 40 17 2 2 2 1 243 2 12 3 12 NA NA
#> 41 16 2 2 0 9 189 2 9 7 12 NA NA
#> 42 32 1 1 0 9 235 1 8 7 12 NA NA
#> 43 19 1 1 2 1 219 2 9 7 10 1 2
#> 44 16 2 2 4 1 221 2 12 7 12 NA NA
#> 45 15 2 2 7 1 225 2 9 2 3 7 1 2 2
#> 46 35 1 2 0 9 200 2 12 3 12 NA NA
#> 47 15 2 2 8 2 203 2 12 7 12 NA NA
#> 48 36 1 2 7 1 230 2 13 3 12 NA NA
#> 49 38 1 2 10 3 304 2 13 7 2 2 2
#> 50 15 1 2 0 9 185 2 9 7 12 NA NA
#> ws6 ws7 KEY PARENT_KEY
#> 1 NA 1 2 3 4 6 7 1 1
#> 2 9 1 2 3 7 8 2 2
#> 3 NA 1 2 3 7 3 3
#> 4 NA 1 2 3 4 5 6 7 8 4 4
#> 5 NA 1 2 8 5 5
#> 6 NA 1 2 3 5 6 6
#> 7 NA 1 2 3 6 7 8 7 7
#> 8 NA 1 2 3 8 8
#> 9 NA 1 2 3 7 8 9 9
#> 10 9 1 2 3 10 10
#> 11 NA 1 2 3 11 11
#> 12 1 1 2 3 7 12 12
#> 13 NA 1 2 3 13 13
#> 14 NA 1 2 3 4 6 7 8 14 14
#> 15 NA 1 2 3 15 15
#> 16 NA 16 16
#> 17 NA 1 2 3 7 8 17 17
#> 18 NA 1 2 3 7 8 18 18
#> 19 NA 1 2 3 7 19 19
#> 20 NA 1 2 3 5 20 20
#> 21 NA 1 2 3 6 7 21 21
#> 22 9 1 2 3 7 8 22 22
#> 23 NA 1 2 3 6 7 23 23
#> 24 1 1 2 3 5 6 7 8 24 24
#> 25 NA 1 2 3 5 6 25 25
#> 26 1 1 2 3 7 8 26 26
#> 27 NA 1 2 3 27 27
#> 28 NA 1 2 3 7 28 28
#> 29 NA 1 2 3 5 29 29
#> 30 9 1 2 3 7 30 30
#> 31 NA 1 2 4 7 31 31
#> 32 1 1 2 3 6 32 32
#> 33 7 1 2 3 8 33 33
#> 34 NA 1 2 3 7 34 34
#> 35 NA 1 2 3 7 8 35 35
#> 36 NA 1 2 3 7 8 36 36
#> 37 NA 1 2 3 7 37 37
#> 38 NA 1 3 5 38 38
#> 39 NA 1 2 3 4 6 7 39 39
#> 40 NA 1 2 3 40 40
#> 41 NA 1 2 3 7 41 41
#> 42 NA 1 2 3 5 42 42
#> 43 7 1 2 3 4 6 7 8 10 43 43
#> 44 NA 2 3 6 7 44 44
#> 45 9 1 2 3 4 5 6 7 8 10 45 45
#> 46 NA 1 2 3 46 46
#> 47 NA 1 2 3 7 8 47 47
#> 48 NA 1 2 3 5 7 48 48
#> 49 2 1 2 3 6 7 49 49
#> 50 NA 1 2 3 7 50 50
names(sampleData2)
#> [1] "wcount.wdata.women.wage" "wcount.wdata.women.wmarried"
#> [3] "wcount.wdata.women.wpregnant" "wcount.wdata.women.wedu1"
#> [5] "wcount.wdata.women.wedu2" "wcount.wdata.women.wanthro"
#> [7] "wcount.wdata.women.screening" "wcount.wdata.wash.ws1"
#> [9] "wcount.wdata.wash.ws2" "wcount.wdata.wash.ws3"
#> [11] "wcount.wdata.wash.ws4" "wcount.wdata.wash.ws5"
#> [13] "wcount.wdata.wash.ws6" "wcount.wdata.wash.ws7"
#> [15] "KEY" "PARENT_KEY"
# Rename sampleData3 dataset
names(sampleData3)
#> [1] "wcount.wdata.ccount.child.csex" "wcount.wdata.ccount.child.card"
#> [3] "wcount.wdata.ccount.child.cdob" "wcount.wdata.ccount.child.cage"
#> [5] "wcount.wdata.ccount.illness.ill1" "wcount.wdata.ccount.illness.ill2"
#> [7] "wcount.wdata.ccount.illness.ill3" "KEY"
#> [9] "PARENT_KEY"
renameODK(sampleData3)
#> csex card cdob cage ill1 ill2 ill3 KEY PARENT_KEY
#> 1 2 1 2016-06-15 6 2 2 2 1 1
#> 2 1 1 2014-08-25 27 2 2 1 2 1
#> 3 2 4 16 1 1 2 3 4
#> 4 2 1 2013-12-24 36 2 2 2 4 7
#> 5 1 4 36 2 2 2 5 9
#> 6 2 4 39 2 2 1 6 12
#> 7 1 1 2013-04-14 44 2 2 2 7 13
#> 8 2 4 42 2 2 2 8 14
#> 9 2 3 2015-12-24 12 2 2 2 9 20
#> 10 2 3 2013-10-24 38 2 1 2 10 20
#> 11 2 1 2014-10-09 26 1 1 1 11 21
#> 12 2 4 36 2 2 2 12 23
#> 13 1 3 2013-08-20 40 2 2 2 13 24
#> 14 2 2 2016-06-24 6 2 2 2 14 25
#> 15 2 1 2014-12-24 24 2 2 2 15 25
#> 16 1 1 2015-05-18 19 2 2 2 16 26
#> 17 2 2 2016-09-24 2 2 2 2 17 31
#> 18 1 2 2013-07-06 41 1 1 2 18 32
#> 19 1 1 2015-03-19 21 2 2 1 19 33
#> 20 1 1 2015-10-08 14 2 2 1 20 34
#> 21 1 4 12 2 1 2 21 37
#> 22 2 1 2013-12-24 36 2 2 2 22 38
#> 23 1 1 2014-02-25 33 2 2 2 23 39
#> 24 2 1 2013-06-20 42 2 2 2 24 42
#> 25 1 2 2014-09-24 27 2 1 2 25 43
#> 26 1 1 2014-09-19 27 2 2 1 26 46
#> 27 2 1 2015-11-24 13 2 2 2 27 48
#> 28 2 1 2014-11-15 25 2 2 2 28 49
#> 29 1 1 2012-01-09 59 2 2 2 29 49
#> 30 1 4 3 2 2 2 30 51
#> 31 1 4 48 2 2 2 31 51
#> 32 1 1 2013-07-21 41 2 2 2 32 52
#> 33 2 1 2014-07-24 29 2 2 2 33 52
#> 34 2 1 2014-05-19 31 1 2 1 34 53
#> 35 1 1 2016-08-28 3 2 2 1 35 53
#> 36 1 1 2014-07-07 29 2 2 1 36 54
#> 37 2 1 2016-03-15 9 2 2 1 37 54
#> 38 1 1 2013-12-24 36 2 2 2 38 55
#> 39 1 2 2013-12-17 36 1 1 2 39 56
#> 40 2 2 2015-10-20 14 1 2 2 40 56
#> 41 2 1 2013-12-24 36 2 1 2 41 57
#> 42 1 1 2016-10-24 2 2 2 2 42 57
#> 43 1 1 2013-12-24 36 2 2 2 43 59
#> 44 2 1 2016-02-29 9 1 2 1 44 60
#> 45 1 1 2016-01-01 11 2 2 1 45 62
#> 46 2 2 2016-03-28 8 2 2 2 46 64
#> 47 2 4 24 2 2 1 47 65
#> 48 2 4 39 2 2 2 48 65
#> 49 2 1 2014-01-05 35 2 2 1 49 67
#> 50 2 1 2014-05-05 31 2 2 2 50 67
names(sampleData3)
#> [1] "wcount.wdata.ccount.child.csex" "wcount.wdata.ccount.child.card"
#> [3] "wcount.wdata.ccount.child.cdob" "wcount.wdata.ccount.child.cage"
#> [5] "wcount.wdata.ccount.illness.ill1" "wcount.wdata.ccount.illness.ill2"
#> [7] "wcount.wdata.ccount.illness.ill3" "KEY"
#> [9] "PARENT_KEY"