Skip to content

Instantly share code, notes, and snippets.

@luluwuluying
Created March 12, 2016 18:39
Show Gist options
  • Save luluwuluying/0b08310e2b675b481ce7 to your computer and use it in GitHub Desktop.
Save luluwuluying/0b08310e2b675b481ce7 to your computer and use it in GitHub Desktop.
Finish Bar Homework
Country Meningitis_encephalitis Respiratory_infections Sepsis Pertussis Malaria Measles Congenital_anomalies HIV_AIDS Diarrhoeal_diseases Asphyxia_trauma
India 0.042488278 0.233534888 0.145938913 0.007182025 0.009314662 0.046933792 0.123114044 0.00663867 0.184781579 0.200073149
Democratic Republic of the Congo 0.040686134 0.221728479 0.075842245 0.01386753 0.212434283 0.06908283 0.048008834 0.02005919 0.150790387 0.147500089
Indonesia 0.025829262 0.27277861 0.106128312 0.01262 0.030445137 0.076689828 0.185003315 0.017677822 0.092133369 0.180694346
Pakistan 0.042190621 0.28618202 0.163435643 0.021985945 0.001921226 0.020857808 0.075568204 0.000843982 0.175454966 0.211559586
Nigeria 0.043200357 0.207813651 0.071262349 0.016492104 0.287175958 0.007996224 0.044873945 0.042612526 0.133019132 0.145553754
Ethiopia 0.034238059 0.262054587 0.115549659 0.028521607 0.043578469 0.034427597 0.081432904 0.034783927 0.140515542 0.22489765
Afghanistan 0.052876527 0.315089385 0.112120879 0.01908775 9.43381E-05 0.061885819 0.056477099 0.000408799 0.207811198 0.174148205
Mali 0.046850218 0.234874811 0.089851198 0.013597077 0.20620155 0.036532122 0.052802281 0.008928094 0.166336987 0.144025662
Sierra Leone 0.046102739 0.230230109 0.074015557 0.00879112 0.190730838 0.070815103 0.056514341 0.007130125 0.184775563 0.130894507
Bangladesh 0.018754232 0.239065674 0.192322275 0.008138118 0.006459039 0.018984428 0.158564658 0.000257278 0.112362898 0.245091401
Myanmar 0.029329333 0.274740457 0.116133107 0.00769747 0.037303122 0.053882288 0.120791063 0.001657917 0.13334386 0.225121383
Burkina Faso 0.03503247 0.209869035 0.076233086 0.014703647 0.314358317 0.021762266 0.057294268 0.008361749 0.13936972 0.123015442
South Africa 0.026292232 0.257882696 0.061669043 0.00828885 0.000596797 0.030436657 0.088193362 0.267398296 0.113623554 0.145618514
China 0.048780687 0.259992331 0.043869168 0.014481639 2.4476E-05 0.006918552 0.251849978 0.006461666 0.074015453 0.29360605
Vietnam 0.02848329 0.196812339 0.107352185 0.006786632 0.000565553 0.038354756 0.273676093 0.019897172 0.20503856 0.123033419
Benin 0.032306708 0.206726375 0.083074392 0.017592762 0.292085542 0.028970938 0.059358435 0.013205995 0.127855968 0.138822884
Angola 0.051363324 0.248229418 0.067710048 0.008436715 0.182513332 0.005897236 0.073851826 0.016722943 0.2112941 0.133981057
Senegal 0.018834609 0.177947812 0.118942515 0.026240926 0.237198352 0.029183834 0.109132823 0.012507357 0.091524426 0.178487345
Zambia 0.029023605 0.202521459 0.086641631 0.017677039 0.223390558 0.015128755 0.053889485 0.081652361 0.122398069 0.167677039
Uganda 0.029290534 0.218147427 0.090384235 0.024491121 0.182589424 0.007763756 0.074038 0.104203721 0.118333757 0.150758025
Ghana 0.024762121 0.183393747 0.101381966 0.01812415 0.2801314 0.01205256 0.088966923 0.010761214 0.107612143 0.172813774
Niger 0.048364345 0.256196682 0.065073554 0.016558071 0.272754752 0.008682072 0.036659502 0.006163095 0.17029959 0.119248337
Sudan 0.039792818 0.286617859 0.130517788 0.022311868 0.032853562 0.007636502 0.100253997 0.007769311 0.174427677 0.197818616
Yemen 0.027826235 0.282474578 0.144747479 0.036165596 0.016508531 0.015657576 0.106284304 0.004765349 0.146406842 0.219163511
Guinea 0.030092447 0.175177662 0.075561285 0.016068172 0.360889252 0.010125149 0.043173385 0.020973524 0.105056286 0.162882838
Malawi 0.021408262 0.182806489 0.088041479 0.020103696 0.198260579 0.010503429 0.064793444 0.169125272 0.100451581 0.14450577
Eritrea 0.032110092 0.297760389 0.111980572 0.033324339 0.006880734 0.039395575 0.126416622 0.009039396 0.154883972 0.188208311
Philippines 0.019249925 0.274340383 0.119275406 0.063193495 0.000254812 0.006532465 0.207695337 0.00048646 0.119738701 0.189233014
Cambodia 0.021854152 0.268806073 0.125603865 0.046353807 0.008166552 0.031170922 0.16068553 0.005291005 0.122613297 0.209454796
Tanzania 0.020390321 0.211356934 0.110368537 0.028318243 0.137397567 0.003838004 0.109020049 0.08188729 0.105019042 0.192404013
Kenya 0.033171338 0.262432188 0.09667439 0.022872401 0.065509155 0.003362342 0.093608725 0.065777577 0.14855052 0.208041365
Cameroon 0.039601494 0.243663186 0.080697385 0.016150972 0.177430788 0.004176645 0.074259987 0.041038414 0.162793371 0.160187757
Burundi 0.038346902 0.288402509 0.110058277 0.018684105 0.079629877 0.009342053 0.067218293 0.020552516 0.182125539 0.185639931
Togo 0.029647157 0.201405804 0.097988726 0.017676943 0.248938687 0.012039808 0.07439627 0.022061382 0.120258891 0.175586332
Egypt 0.009216383 0.198714202 0.04814998 0.016544531 0 0.006788653 0.388391854 0.000584454 0.093018028 0.238591917
Rwanda 0.026267862 0.269683385 0.111866069 0.029209863 0.066475203 0.00917624 0.120972261 0.023045671 0.142056598 0.201246848
Algeria 0.012800329 0.217810938 0.124101581 0.012594976 0 0.008693271 0.310767335 0.008282566 0.085837497 0.219111507
South Sudan 0.061218869 0.296533816 0.087461148 0.019671873 0.084038242 0.004917968 0.055199276 0.041822402 0.154502892 0.194633513
Namibia 0.02238806 0.228144989 0.1108742 0.036780384 0.000533049 0.060767591 0.132729211 0.105010661 0.115671642 0.187100213
Mauritania 0.038793676 0.243656171 0.124219477 0.018998273 0.149993357 0.013418361 0.088082902 0.005048492 0.152384748 0.165404544
Thailand 0.014521193 0.145604396 0.084968603 0.01255887 0.007849294 0.01255887 0.522566719 0.009026688 0.049254317 0.141091052
Botswana 0.018181818 0.213636364 0.137121212 0.006060606 0.000757576 0.027272727 0.173484848 0.093939394 0.10530303 0.224242424
Djibouti 0.030907278 0.248255234 0.114656032 0.003988036 0.027916251 0.031904287 0.13559322 0.044865404 0.147557328 0.214356929
Guinea-Bissau 0.036873968 0.197578426 0.094111172 0.011007155 0.247477527 0.005320125 0.053935058 0.050082554 0.131352045 0.17226197
Lesotho 0.023078874 0.178037028 0.111336546 0.014202384 0 0.006086736 0.065178798 0.280750697 0.107278722 0.214050216
Iraq 0.020818274 0.254445569 0.14500506 0.010987422 0 0.00110838 0.216712448 0 0.107512891 0.243409956
Gambia 0.021947528 0.176841574 0.105196771 0.018415742 0.282795156 0.00554995 0.095610494 0.009586276 0.102926337 0.181130172
C̫te d'Ivoire 0.033505256 0.211543762 0.104571046 0.014921847 0.220185834 0.000393716 0.061833143 0.033367455 0.137505414 0.182172526
Ukraine 0.042291426 0.186466744 0.054209919 0.020761246 0 0.007304883 0.505959246 0.013071895 0.038062284 0.131872357
Gabon 0.017891683 0.171179884 0.102998066 0.028046422 0.261121857 0.006769826 0.120889749 0.030947776 0.088491296 0.171663443
Jordan 0.012974052 0.18762475 0.109780439 0.018463074 0 0.004491018 0.424650699 0 0.065868263 0.176147705
Uzbekistan 0.028790661 0.324042497 0.073452256 0.007345226 0 0.000327912 0.215044596 0.002229801 0.16730063 0.181466422
Tajikistan 0.025881756 0.282796245 0.135879218 0.006216696 0 0.000507485 0.163283431 0.004059883 0.143110886 0.2382644
Sao Tome and Principe 0.023255814 0.241860465 0.102325581 0.004651163 0.125581395 0.018604651 0.153488372 0.009302326 0.130232558 0.190697674
Bosnia and Herzegovina 0.016260163 0.105691057 0.089430894 0.016260163 0 0.024390244 0.552845528 0 0.008130081 0.18699187
Bulgaria 0.023157895 0.273684211 0.035789474 0 0 0.006315789 0.461052632 0 0.010526316 0.189473684
Iran 0.014645536 0.231923022 0.119711334 0.019244375 0 0.000212254 0.351209849 0.004669591 0.060563181 0.197820858
Syria 0.007953724 0.16582309 0.100747168 0.031332851 0 0.000482044 0.311159315 0 0.187515064 0.194986744
Swaziland 0.028311426 0.228008089 0.098584429 0.021233569 0.000505561 0.001011122 0.086450961 0.215874621 0.1380182 0.182002022
Albania 0.044642857 0.19047619 0.068452381 0.011904762 0 0.00297619 0.532738095 0 0.017857143 0.130952381
Qatar 0.011111111 0.088888889 0.055555556 0.022222222 0 0.011111111 0.611111111 0 0.011111111 0.188888889
Samoa 0.041666667 0.208333333 0.083333333 0.020833333 0 0.020833333 0.4375 0 0.0625 0.125
Andorra 0 0 0 0 0 0 1 0 0 0
Antigua and Barbuda 0 0.166666667 0 0 0 0 0.166666667 0 0 0.666666667
Argentina 0.028661088 0.176569038 0.115690377 0.008995816 0 0 0.540376569 0.002301255 0.027615063 0.099790795
Armenia 0.037037037 0.179012346 0.092592593 0.012345679 0 0 0.50308642 0.00308642 0.018518519 0.154320988
Austria 0.039772727 0.045454545 0.034090909 0 0 0 0.693181818 0 0.005681818 0.181818182
Azerbaijan 0.021904762 0.284444444 0.100634921 0.011111111 0 0 0.246984127 0.001269841 0.131111111 0.202539683
Bahamas 0 0.568181818 0.113636364 0 0 0 0.181818182 0 0 0.136363636
Bahrain 0.037974684 0.075949367 0.063291139 0 0 0 0.506329114 0 0 0.316455696
Barbados 0 0.214285714 0.035714286 0 0 0 0.464285714 0 0 0.285714286
Belarus 0.024561404 0.105263158 0.045614035 0.031578947 0 0 0.656140351 0.003508772 0.010526316 0.122807018
Belgium 0.041666667 0.0625 0.054166667 0 0 0 0.645833333 0 0 0.195833333
Belize 0.020408163 0.142857143 0.142857143 0 0 0 0.326530612 0.020408163 0.081632653 0.265306122
Bhutan 0.023333333 0.286666667 0.143333333 0.006666667 0 0 0.186666667 0.003333333 0.13 0.22
Bolivia 0.020930583 0.256286704 0.117602771 0.046830297 0 0 0.203583798 0.00587261 0.124228279 0.22466496
Brunei Darussalam 0.035714286 0.107142857 0.035714286 0.035714286 0 0 0.607142857 0 0 0.178571429
Cabo Verde 0.026845638 0.255033557 0.093959732 0.013422819 0 0 0.322147651 0.053691275 0.100671141 0.134228188
Canada 0.020452099 0.052744887 0.075349839 0.003229279 0 0 0.611410118 0 0.009687836 0.227125942
Chile 0.013487476 0.11849711 0.061657033 0.006743738 0 0 0.713872832 0.003853565 0.004816956 0.077071291
Costa Rica 0.033492823 0.038277512 0.028708134 0.014354067 0 0 0.720095694 0 0.011961722 0.153110048
Croatia 0.086419753 0.037037037 0.086419753 0 0 0 0.62962963 0 0 0.160493827
Cuba 0.049132948 0.199421965 0.121387283 0 0 0 0.401734104 0 0.023121387 0.205202312
Cyprus 0 0.041666667 0.041666667 0.041666667 0 0 0.708333333 0 0 0.166666667
Czech Republic 0.03271028 0.098130841 0.135514019 0 0 0 0.490654206 0 0.018691589 0.224299065
Denmark 0.016129032 0.032258065 0.016129032 0 0 0 0.677419355 0 0.048387097 0.209677419
Dominica 0 0.1 0.2 0 0 0 0.1 0 0 0.6
Ecuador 0.038817006 0.225772379 0.086348033 0.015579614 0 0 0.417480856 0.001848429 0.076841827 0.137311856
El Salvador 0.033649698 0.230371009 0.06557377 0.021570319 0 0 0.399482312 0.035375324 0.091458154 0.122519413
Estonia 0.08 0.12 0.2 0 0 0 0.44 0 0 0.16
Fiji 0.062222222 0.244444444 0.097777778 0.013333333 0 0 0.364444444 0 0.084444444 0.133333333
Finland 0.028571429 0.114285714 0.057142857 0 0 0 0.671428571 0 0 0.128571429
France 0.035807292 0.045572917 0.065755208 0.001953125 0 0 0.573567708 0.001953125 0.026692708 0.248697917
Georgia 0.023017903 0.140664962 0.140664962 0.012787724 0 0 0.501278772 0.00511509 0.010230179 0.166240409
Germany 0.010797342 0.045681063 0.049833887 0.000830565 0 0 0.730066445 0 0.009136213 0.153654485
Greece 0.011406844 0.041825095 0 0 0 0 0.840304183 0 0 0.106463878
Grenada 0 0 0.181818182 0 0 0 0.454545455 0 0 0.363636364
Guatemala 0.020355132 0.278042443 0.137180598 0.009744478 0 0 0.188501516 0.022845388 0.117583369 0.225747077
Hungary 0.026415094 0.109433962 0.056603774 0 0 0 0.664150943 0 0.00754717 0.135849057
Iceland 0 0 0 0 0 0 1 0 0 0
Ireland 0.01986755 0.046357616 0.013245033 0 0 0 0.774834437 0 0.006622517 0.139072848
Israel 0.032142857 0.032142857 0.05 0 0 0 0.789285714 0 0.007142857 0.089285714
Italy 0.01774398 0.02661597 0.093789607 0 0 0 0.62991128 0.001267427 0.001267427 0.229404309
Jamaica 0.022573363 0.155756208 0.128668172 0.020316027 0 0 0.433408578 0.0248307 0.045146727 0.169300226
Japan 0.014534884 0.118604651 0.038372093 0 0 0 0.712209302 0 0.035465116 0.080813953
Kazakhstan 0.009794629 0.223064771 0.103633491 0.018957346 0 0 0.350078989 0.002843602 0.073933649 0.217693523
Kiribati 0.036144578 0.313253012 0.096385542 0 0 0 0.156626506 0 0.180722892 0.21686747
Kuwait 0.029154519 0.148688047 0.020408163 0 0 0 0.743440233 0 0.005830904 0.052478134
Kyrgyzstan 0.012987013 0.226600985 0.122257053 0.012539185 0 0 0.303627407 0.000447828 0.085087326 0.236453202
Latvia 0.007633588 0.022900763 0.099236641 0 0 0 0.419847328 0 0 0.450381679
Lebanon 0.010135135 0.138513514 0.084459459 0.023648649 0 0 0.466216216 0.023648649 0.040540541 0.212837838
Libya 0.01242236 0.144927536 0.090062112 0.023809524 0 0 0.522774327 0 0.032091097 0.173913043
Lithuania 0.03960396 0.059405941 0.178217822 0 0 0 0.554455446 0 0.00990099 0.158415842
Luxembourg 0.2 0 0.2 0 0 0 0.4 0 0 0.2
Maldives 0.023255814 0.139534884 0.069767442 0.023255814 0 0 0.558139535 0 0.023255814 0.162790698
Malta 0.142857143 0 0 0 0 0 0.785714286 0 0 0.071428571
Marshall Islands 0.034482759 0.344827586 0.103448276 0 0 0 0.206896552 0 0.137931034 0.172413793
Mauritius 0.018348624 0.183486239 0.119266055 0 0 0 0.541284404 0.009174312 0.027522936 0.100917431
Mexico 0.017794836 0.217085369 0.120260526 0.001628286 0 0 0.468655501 0.004419632 0.050883926 0.119271924
Micronesia 0.020408163 0.326530612 0.102040816 0 0 0 0.204081633 0 0.142857143 0.204081633
Mongolia 0.019917012 0.27966805 0.08879668 0.009958506 0 0 0.271369295 0.002489627 0.128630705 0.199170124
Montenegro 0 0.090909091 0.045454545 0 0 0 0.136363636 0 0 0.727272727
Morocco 0.014011417 0.221217288 0.16250278 0.010971903 0 0 0.248869449 0.002298169 0.095188672 0.244940322
Netherlands 0.044502618 0.036649215 0.091623037 0 0 0 0.612565445 0 0.002617801 0.212041885
New Zealand 0.01875 0.13125 0.05625 0 0 0 0.54375 0 0.05 0.2
Nicaragua 0.029936975 0.263130252 0.074579832 0.013130252 0 0 0.324054622 0.020483193 0.112920168 0.161764706
Norway 0.02247191 0.04494382 0.02247191 0 0 0 0.707865169 0 0.011235955 0.191011236
Oman 0.010799136 0.11663067 0.058315335 0.032397408 0 0 0.539956803 0.006479482 0.023758099 0.211663067
Palau 0 0 0 0 0 0 1 0 0 0
Panama 0.021454112 0.219308701 0.117997616 0.021454112 0 0 0.376638856 0.003575685 0.154946365 0.084624553
Paraguay 0.025566811 0.199228172 0.119150989 0.082006753 0 0 0.344428365 0.008200675 0.089242644 0.132175591
Poland 0.016363636 0.079090909 0.066363636 0 0 0 0.721818182 0.000909091 0.005454545 0.11
Portugal 0.019354839 0.064516129 0.096774194 0 0 0 0.651612903 0 0 0.167741935
South Korea 0.050147493 0.079646018 0.067846608 0 0 0 0.628318584 0 0.022123894 0.151917404
Moldova 0.034229829 0.281173594 0.058679707 0 0 0 0.547677262 0.004889976 0.014669927 0.058679707
Romania 0.020612117 0.45971268 0.018113679 0 0 0 0.407245472 0.001873829 0.012492192 0.079950031
Russia 0.035391314 0.145919393 0.066205203 0.017863124 0 0 0.567712404 0.025120018 0.014737077 0.127051468
Saint Kitts and Nevis 0 0 0.2 0 0 0 0.2 0 0 0.6
Saint Lucia 0 0.380952381 0 0 0 0 0.619047619 0 0 0
Saint Vincent and the Grenadines 0 0.1 0.1 0 0 0 0.4 0 0 0.4
Saudi Arabia 0.014044944 0.138342697 0.077013109 0.023876404 0 0 0.502808989 0 0.034644195 0.209269663
Serbia 0.019762846 0.130434783 0.04743083 0 0 0 0.529644269 0.003952569 0 0.268774704
Seychelles 0 0.1 0.2 0 0 0 0.5 0 0 0.2
Singapore 0.028571429 0.185714286 0.014285714 0 0 0 0.571428571 0 0.028571429 0.171428571
Slovakia 0.029850746 0.154228856 0.029850746 0 0 0 0.651741294 0 0.009950249 0.124378109
Slovenia 0 0.076923077 0.230769231 0 0 0 0.538461538 0 0 0.153846154
Spain 0.027700831 0.035087719 0.127423823 0.010156971 0 0 0.597414589 0.000923361 0.003693444 0.197599261
Sri Lanka 0.015041494 0.12033195 0.071576763 0.018153527 0 0 0.566390041 0.003112033 0.037344398 0.168049793
Suriname 0.052631579 0.166666667 0.175438596 0 0 0 0.315789474 0.078947368 0.01754386 0.192982456
Sweden 0.012195122 0.079268293 0.091463415 0.006097561 0 0 0.609756098 0 0.006097561 0.195121951
Switzerland 0.012345679 0.024691358 0.074074074 0 0 0 0.654320988 0.00617284 0.00617284 0.222222222
Macedonia 0.153846154 0.153846154 0.057692308 0 0 0 0.423076923 0 0.019230769 0.192307692
Tonga 0.055555556 0.166666667 0.111111111 0 0 0 0.5 0 0.055555556 0.111111111
Trinidad and Tobago 0.020100503 0.155778894 0.085427136 0 0 0 0.527638191 0.015075377 0.010050251 0.185929648
Tunisia 0.011198946 0.164031621 0.083003953 0.011857708 0 0 0.46113307 0.001317523 0.046113307 0.221343874
Turkey 0.041083985 0.185193964 0.10010271 0.018961839 0 0 0.453582998 0.000711069 0.019119855 0.181243581
Turkmenistan 0.029768786 0.289306358 0.096820809 0.005491329 0 0 0.199421965 0 0.162427746 0.216763006
Tuvalu 0 0.333333333 0 0 0 0 0.333333333 0 0 0.333333333
United Arab Emirates 0.010791367 0.079136691 0.04676259 0.025179856 0 0 0.625899281 0 0.014388489 0.197841727
United Kingdom 0.037868163 0.097475456 0.031556802 0.001402525 0 0 0.662692847 0.000701262 0.000701262 0.167601683
Uruguay 0.044303797 0.215189873 0.17721519 0 0 0 0.462025316 0 0.022151899 0.079113924
Australia 0.022887324 0.054577465 0.029929577 0.003521127 0.001760563 0 0.625 0 0.003521127 0.258802817
Dominican Republic 0.015794092 0.2260895 0.132787365 0.012576777 0.000292483 0 0.293653115 0.01199181 0.088037438 0.21877742
Honduras 0.025048924 0.225440313 0.12446184 0.016046967 0.000391389 0 0.304500978 0.02074364 0.112328767 0.171037182
United States of America 0.017184943 0.074286234 0.065375523 0.002636843 9.09256E-05 0 0.67012184 0.000272777 0.048917985 0.12111293
Vanuatu 0.03030303 0.181818182 0.075757576 0.090909091 0.03030303 0 0.333333333 0 0.090909091 0.166666667
Malaysia 0.035095321 0.132582322 0.05762565 0.042461005 0.001299827 0 0.510831889 0.01169844 0.035528596 0.17287695
Nepal 0.02014218 0.248000592 0.173430095 0.046504739 0.000222156 0 0.148326422 0.005702014 0.115077014 0.242594787
Peru 0.033863034 0.200340522 0.079833523 0.020998865 0.000756716 0 0.416950435 0.013810064 0.082860386 0.150586455
Solomon Islands 0.021538462 0.28 0.110769231 0.052307692 0.024615385 0 0.193846154 0 0.116923077 0.2
Venezuela 0.021458375 0.18319094 0.152791576 0.004172462 0.003179018 0 0.390820584 0.006755414 0.082455792 0.155175839
Colombia 0.020647111 0.17638172 0.145914642 0.001636661 0.002392043 0 0.450585421 0.002643837 0.035251165 0.1645474
Brazil 0.028654097 0.140703752 0.167397797 0.000700019 0.001540041 0 0.412404331 0.003500093 0.036960986 0.208138884
Guyana 0.018796992 0.116541353 0.127819549 0 0.176691729 0 0.184210526 0.022556391 0.105263158 0.248120301
Lao 0.038085005 0.304680038 0.117359121 0.027578797 0.010148042 0 0.092287488 0.004178606 0.180276982 0.225405922
Timor 0.030323915 0.281185389 0.126809097 0.033769814 0.059958649 0 0.095796003 0 0.147484493 0.22467264
Haiti 0.045797727 0.318924749 0.097652037 0.029702149 0.008711524 0 0.110014104 0.015846677 0.191570563 0.18178047
Comoros 0.028700906 0.224320242 0.114048338 0.018882175 0.217522659 0 0.070996979 0.01510574 0.129154079 0.181268882
Equatorial Guinea 0.043778802 0.216013825 0.081221198 0.020737327 0.211981567 0 0.052419355 0.103110599 0.113479263 0.157258065
Papua New Guinea 0.031617301 0.25364363 0.100023507 0.026680771 0.16690174 0 0.085448989 0.012458862 0.131523272 0.191701928
Congo 0.015471167 0.152777778 0.092123769 0.0302391 0.299050633 0 0.109177215 0.077355837 0.071905767 0.151898734
Liberia 0.022644456 0.193779282 0.09903696 0.021863613 0.295809474 0 0.072358147 0.009760541 0.109578345 0.175169183
Madagascar 0.031454602 0.276509509 0.106800152 0.030657845 0.112654588 0 0.088855787 0.016420134 0.141892126 0.194755257
Central African Republic 0.047093313 0.198041417 0.056823852 0.012287924 0.340506487 0 0.031749002 0.041417166 0.12487525 0.147205589
Mozambique 0.027938745 0.194869825 0.094053206 0.017718475 0.245236385 0 0.057129974 0.09131444 0.116898515 0.154840434
Chad 0.060815839 0.245011336 0.052093249 0.013360793 0.270434918 0 0.037590211 0.027379242 0.175230612 0.118083799
<!DOCTYPE html>
<!-- Modified example from enjalot: http://bl.ocks.org/enjalot/1429426 -->
<html>
<head>
<title>Top Causes of Deaths Bar Chart</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<style type="text/css">
body {
padding: 50px;
font-family: sans-serif;
font-size: 12pt;
}
button {
margin: 5px;
font-size: 15pt;
padding: 3px;
cursor: pointer;
}
input {
margin: 5px;
font-size: 15pt;
padding: 3px;
}
p {
width: 500px;
padding-left: 50px;
}
#chart {
padding-left: 75px;
}
#menu {
padding: 20px 75px;
}
#menu select {
background: #ccc;
width: 220px;
padding: 5px;
font-size: 14px;
line-height: 1;
border: 0;
border-radius: 0;
height: 34px;
}
.labels {
fill: white;
font-size: 10px;
}
</style>
</head>
<body>
<h2>Top 20 Contributors to Death of Under 4 Year Olds By Country</h2>
<p>For each country, these causes contributed what percent of the total deaths of under four year olds? Sorted to show the top 20 countries per disease cost. (Need real source here.)
<p>Blue bars were present in your previous selection.
<p>(Code Based on <a href="http://bl.ocks.org/enjalot/1429426">an example from enjalot</a>.)
<div id="menu">
<select>
<option value="Measles">Measles</option>
<option value="Sepsis">Sepsis</option>
<option value="Malaria">Malaria</option>
<option value="Pertussis">Pertussis</option>
<option value="Congenital_anomalies">Congenital_anomalies</option>
<option value="HIV_AIDS">HIV_AIDS</option>
<option value="Diarrhoeal_diseases">Diarrhoeal_diseases</option>
<option value="Asphyxia_trauma">Asphyxia_trauma</option>
//TODO: fill in the others here. What do you use for the values?
</select>
</div>
<div id="chart">
</div>
<script type="text/javascript">
var fullwidth = 400;
var fullheight = 500;
var margin = {top: 10, right: 20, bottom: 20, left: 10};
var height = fullheight - margin.top - margin.bottom;
var width = fullwidth - margin.left - margin.right;
var format = d3.format(".1%");
//setup the svg
var vis = d3.select("#chart").append("svg");
var svg = vis
.attr("width", fullwidth)
.attr("height", fullheight)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
// load the data and do stuff
d3.csv("deaths_04yearsold_2013percent.csv", function(error, data) {
var column = d3.select("#menu select").property("value");
var dataset = top20_by_column(data, column); // you need to finish this function below.
console.log(column, dataset);
//setup our ui -- requires access to data variable, so inside csv
d3.select("#menu select")
.on("change", function() {
column = d3.select("#menu select").property("value");//TODO: How do you get the current value of the select menu?
dataset = top20_by_column(data, column);//TODO: How do you get the current filter/storted data?
console.log(column, dataset);
redraw(dataset, column);
});
redraw(dataset, column);
}); // end csv
//make the bars for the first data set. They will be red at first.
function top20_by_column(data, column) {
var top20 = data.sort(function(a, b) {
return b[column] - a[column]; // descending order, biggest at the top!
}).slice(0, 20);
// TODO: fill in this function. The answer direction is in the wiki page for week8.
// You want to sort the data by the column, descending order, and then slice.
return top20;
}
// This function is used to draw and update the data. It takes different data each time.
function redraw(data, column) {
var max = d3.max(data, function(d) {return +d[column];});
xScale = d3.scale.linear()
.domain([0, max])//TODO: what goes here?])
.range([0, width]);
yScale = d3.scale.ordinal()
.domain(d3.range(data.length))
.rangeBands([0, height], .2);
var bars = svg.selectAll("rect.bar")
.data(data, function (d){ return d.Country;})//TODO: what is your key value?}); // key function!
//update -- existing bars get blue when we "redraw". We don't change labels.
bars
.attr("fill", "steelblue");
//enter - new bars get set to darkorange when we "redraw."
bars.enter()
.append("rect")
.attr("class", "bar")
.attr("fill", "darkorange");
//exit -- remove ones that aren't in the index set
bars.exit()
.transition()
.duration(300)
.attr("width", 0)
.remove();
//TODO: what goes here at the end of exit?
// transition -- move the bars to proper widths and location
bars
.transition()
.duration(300)
.ease("quad")
.attr("width", function(d) {
return xScale(+d[column]); //TODO: what goes here?;
})
.attr("height", yScale.rangeBand())//TODO: In an ordinal scale bar chart, what goes here?)
.attr("fill", "darkorange") // do what you like with the colors
.attr("transform", function(d,i) {
return "translate(0," + yScale(i) + ")";
});
// We are attaching the labels separately, not in a group with the bars...
var labels = svg.selectAll("text.labels")
.data(data, function (d) {
return d.Country;})
//TODO: what is your key here? same as above.}); // key function!
// everything gets a class and a text field. But we assign attributes in the transition.
labels.enter()
.append("text")
.attr("class", "labels");
labels.exit()
.remove();
labels.transition()
.duration(300)//TODO: How long do you want this to last?
.text(function(d) {
return d.Country + " " + format(d[column]);//TODO: what goes here?;
})
.attr("transform", function(d,i) {
return "translate(" + xScale(+d[column]) + "," + yScale(i) + ")"
})
.attr("dy", "1.2em")
.attr("dx", "-3px")
.attr("text-anchor", "end");
} // end of draw function
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment