Skip to content

Instantly share code, notes, and snippets.

@lmelgar
lmelgar / diarrhoeal.csv
Created November 2, 2015 20:33
"Week 10: tooltips."
country region year Diarrhoeal diseases HIV Pertussis Measles Meningitis and encephalitis Malaria Respiratory infections Prematurity Birth asphixia Sepsis and infections Perinatal and nutritional Congenital anomalies Injuries Other
Afghanistan South Asia 2013 13 0 1.2 3.9 3.3 0 19.8 12.3 10.9 7 9.9 3.5 6.8 5.8
Afghanistan South Asia 2012 13.9 0 1.2 3.2 3.5 0 20.3 12.8 11 6.9 10.1 3.5 6.9 6
Afghanistan South Asia 2011 14.8 0 1.2 4.4 3.7 0 21 13.1 11 6.9 10.4 3.4 7.1 6.2
Afghanistan South Asia 2010 15.7 0 1.2 3 3.9 0 21.6 12.1 11.5 7.6 10.9 3.4 7.3 6.4
Afghanistan South Asia 2009 16.7 0 1.3 4.1 4.1 0 22.3 11.4 11.8 7.8 11.5 3.3 7.5 6.6
Afghanistan South Asia 2008 16.4 0 1.3 2.1 5.7 0 24.7 11.5 11.5 7.7 11.2 3.1 7.1 6.2
Afghanistan South Asia 2007 17.4 0 1.3 1.6 5.9 0 25.2 11.4 11.7 7.6 11.7 3.1 7.3 6.3
Afghanistan South Asia 2006 18.4 0 1.3 3.3 6.1 0 25.7 11 11.7 7.9 12.3 3 7.5 6.4
Afghanistan South Asia 2005 19.5 0 1.3 2.3 6.4 0 26.1 10.9 11.7 7.9 12.8 2.9 7.7 6.5
@lmelgar
lmelgar / diarrhoeal.csv
Created November 2, 2015 20:32
"Week 10, Small Multiples."
country region year diarrhoeal_diseases hiv pertussis measles meningitis_encephalitis malaria respiratory_infections prematurity birth_asphixia sepsis_infectious_newborn perinatal_nutritional congenital_anomalies injuries other
Afghanistan South Asia 2013 13 0 1.2 3.9 3.3 0 19.8 12.3 10.9 7 9.9 3.5 6.8 5.8
Afghanistan South Asia 2012 13.9 0 1.2 3.2 3.5 0 20.3 12.8 11 6.9 10.1 3.5 6.9 6
Afghanistan South Asia 2011 14.8 0 1.2 4.4 3.7 0 21 13.1 11 6.9 10.4 3.4 7.1 6.2
Afghanistan South Asia 2010 15.7 0 1.2 3 3.9 0 21.6 12.1 11.5 7.6 10.9 3.4 7.3 6.4
Afghanistan South Asia 2009 16.7 0 1.3 4.1 4.1 0 22.3 11.4 11.8 7.8 11.5 3.3 7.5 6.6
Afghanistan South Asia 2008 16.4 0 1.3 2.1 5.7 0 24.7 11.5 11.5 7.7 11.2 3.1 7.1 6.2
Afghanistan South Asia 2007 17.4 0 1.3 1.6 5.9 0 25.2 11.4 11.7 7.6 11.7 3.1 7.3 6.3
Afghanistan South Asia 2006 18.4 0 1.3 3.3 6.1 0 25.7 11 11.7 7.9 12.3 3 7.5 6.4
Afghanistan South Asia 2005 19.5 0 1.3 2.3 6.4 0 26.1 10.9 11.7 7.9 12.8 2.9 7.7 6.5
@lmelgar
lmelgar / diarrhoeal.csv
Created November 2, 2015 16:02
Small multiples
Afghanistan South Asia 2013 13 0 1.2 3.9 3.3 0 19.8 12.3 10.9 7 9.9 3.5 6.8 5.8
Afghanistan South Asia 2012 13.9 0 1.2 3.2 3.5 0 20.3 12.8 11 6.9 10.1 3.5 6.9 6
Afghanistan South Asia 2011 14.8 0 1.2 4.4 3.7 0 21 13.1 11 6.9 10.4 3.4 7.1 6.2
Afghanistan South Asia 2010 15.7 0 1.2 3 3.9 0 21.6 12.1 11.5 7.6 10.9 3.4 7.3 6.4
Afghanistan South Asia 2009 16.7 0 1.3 4.1 4.1 0 22.3 11.4 11.8 7.8 11.5 3.3 7.5 6.6
Afghanistan South Asia 2008 16.4 0 1.3 2.1 5.7 0 24.7 11.5 11.5 7.7 11.2 3.1 7.1 6.2
Afghanistan South Asia 2007 17.4 0 1.3 1.6 5.9 0 25.2 11.4 11.7 7.6 11.7 3.1 7.3 6.3
Afghanistan South Asia 2006 18.4 0 1.3 3.3 6.1 0 25.7 11 11.7 7.9 12.3 3 7.5 6.4
Afghanistan South Asia 2005 19.5 0 1.3 2.3 6.4 0 26.1 10.9 11.7 7.9 12.8 2.9 7.7 6.5
@lmelgar
lmelgar / diarrhoeal.csv
Created October 26, 2015 20:24
Week 9: "Grouped Bars."
Afghanistan South Asia 2013 13 0 1.2 3.9 3.3 0 19.8 12.3 10.9 7 9.9 3.5 6.8 5.8
Afghanistan South Asia 2012 13.9 0 1.2 3.2 3.5 0 20.3 12.8 11 6.9 10.1 3.5 6.9 6
Afghanistan South Asia 2011 14.8 0 1.2 4.4 3.7 0 21 13.1 11 6.9 10.4 3.4 7.1 6.2
Afghanistan South Asia 2010 15.7 0 1.2 3 3.9 0 21.6 12.1 11.5 7.6 10.9 3.4 7.3 6.4
Afghanistan South Asia 2009 16.7 0 1.3 4.1 4.1 0 22.3 11.4 11.8 7.8 11.5 3.3 7.5 6.6
Afghanistan South Asia 2008 16.4 0 1.3 2.1 5.7 0 24.7 11.5 11.5 7.7 11.2 3.1 7.1 6.2
Afghanistan South Asia 2007 17.4 0 1.3 1.6 5.9 0 25.2 11.4 11.7 7.6 11.7 3.1 7.3 6.3
Afghanistan South Asia 2006 18.4 0 1.3 3.3 6.1 0 25.7 11 11.7 7.9 12.3 3 7.5 6.4
Afghanistan South Asia 2005 19.5 0 1.3 2.3 6.4 0 26.1 10.9 11.7 7.9 12.8 2.9 7.7 6.5
@lmelgar
lmelgar / diarrhoeal.csv
Created October 26, 2015 20:22
Week 9: "Stacked Bars."
Afghanistan South Asia 2013 13 0 1.2 3.9 3.3 0 19.8 12.3 10.9 7 9.9 3.5 6.8 5.8
Afghanistan South Asia 2012 13.9 0 1.2 3.2 3.5 0 20.3 12.8 11 6.9 10.1 3.5 6.9 6
Afghanistan South Asia 2011 14.8 0 1.2 4.4 3.7 0 21 13.1 11 6.9 10.4 3.4 7.1 6.2
Afghanistan South Asia 2010 15.7 0 1.2 3 3.9 0 21.6 12.1 11.5 7.6 10.9 3.4 7.3 6.4
Afghanistan South Asia 2009 16.7 0 1.3 4.1 4.1 0 22.3 11.4 11.8 7.8 11.5 3.3 7.5 6.6
Afghanistan South Asia 2008 16.4 0 1.3 2.1 5.7 0 24.7 11.5 11.5 7.7 11.2 3.1 7.1 6.2
Afghanistan South Asia 2007 17.4 0 1.3 1.6 5.9 0 25.2 11.4 11.7 7.6 11.7 3.1 7.3 6.3
Afghanistan South Asia 2006 18.4 0 1.3 3.3 6.1 0 25.7 11 11.7 7.9 12.3 3 7.5 6.4
Afghanistan South Asia 2005 19.5 0 1.3 2.3 6.4 0 26.1 10.9 11.7 7.9 12.8 2.9 7.7 6.5
@lmelgar
lmelgar / index.html
Created October 26, 2015 20:21
Week 9: "JS homework".
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<h2>Look in the console.</h2>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<script>
d3.csv("deaths_04yearsold_excerpt.csv", function(error, data) {
@lmelgar
lmelgar / diarrhoeal.csv
Created October 26, 2015 14:51
Doubts stacked bar
Afghanistan South Asia 2013 13 0 1.2 3.9 3.3 0 19.8 12.3 10.9 7 9.9 3.5 6.8 5.8
Afghanistan South Asia 2012 13.9 0 1.2 3.2 3.5 0 20.3 12.8 11 6.9 10.1 3.5 6.9 6
Afghanistan South Asia 2011 14.8 0 1.2 4.4 3.7 0 21 13.1 11 6.9 10.4 3.4 7.1 6.2
Afghanistan South Asia 2010 15.7 0 1.2 3 3.9 0 21.6 12.1 11.5 7.6 10.9 3.4 7.3 6.4
Afghanistan South Asia 2009 16.7 0 1.3 4.1 4.1 0 22.3 11.4 11.8 7.8 11.5 3.3 7.5 6.6
Afghanistan South Asia 2008 16.4 0 1.3 2.1 5.7 0 24.7 11.5 11.5 7.7 11.2 3.1 7.1 6.2
Afghanistan South Asia 2007 17.4 0 1.3 1.6 5.9 0 25.2 11.4 11.7 7.6 11.7 3.1 7.3 6.3
Afghanistan South Asia 2006 18.4 0 1.3 3.3 6.1 0 25.7 11 11.7 7.9 12.3 3 7.5 6.4
Afghanistan South Asia 2005 19.5 0 1.3 2.3 6.4 0 26.1 10.9 11.7 7.9 12.8 2.9 7.7 6.5
@lmelgar
lmelgar / diarrhoeal.csv
Created October 22, 2015 21:30
Doubt about data array
country region year diarrhoeal_diseases hiv pertussis measles meningitis_encephalitis malaria respiratory_infections prematurity birth_asphixia sepsis_infectious_newborn perinatal_nutritional congenital_anomalies injuries other
Afghanistan South Asia 2013 13 0 1.2 3.9 3.3 0 19.8 12.3 10.9 7 9.9 3.5 6.8 5.8
Afghanistan South Asia 2012 13.9 0 1.2 3.2 3.5 0 20.3 12.8 11 6.9 10.1 3.5 6.9 6
Afghanistan South Asia 2011 14.8 0 1.2 4.4 3.7 0 21 13.1 11 6.9 10.4 3.4 7.1 6.2
Afghanistan South Asia 2010 15.7 0 1.2 3 3.9 0 21.6 12.1 11.5 7.6 10.9 3.4 7.3 6.4
Afghanistan South Asia 2009 16.7 0 1.3 4.1 4.1 0 22.3 11.4 11.8 7.8 11.5 3.3 7.5 6.6
Afghanistan South Asia 2008 16.4 0 1.3 2.1 5.7 0 24.7 11.5 11.5 7.7 11.2 3.1 7.1 6.2
Afghanistan South Asia 2007 17.4 0 1.3 1.6 5.9 0 25.2 11.4 11.7 7.6 11.7 3.1 7.3 6.3
Afghanistan South Asia 2006 18.4 0 1.3 3.3 6.1 0 25.7 11 11.7 7.9 12.3 3 7.5 6.4
Afghanistan South Asia 2005 19.5 0 1.3 2.3 6.4 0 26.1 10.9 11.7 7.9 12.8 2.9 7.7 6.5
@lmelgar
lmelgar / deaths_04yearsold_2013percent.csv
Created October 19, 2015 15:57
Finished Bar Homework
We can make this file beautiful and searchable if this error is corrected: It looks like row 8 should actually have 11 columns, instead of 8 in line 7.
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.0
@lmelgar
lmelgar / index.html
Created October 19, 2015 15:54
Scatter Homework
<!DOCTYPE html>
<!-- Modified example from enjalot: http://bl.ocks.org/enjalot/1429426 -->
<html>
<head>
<title>Bar Transition Example</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700);
body {