Published
Edited
Sep 30, 2020
1 fork
Importers
1 star
Insert cell
md`# Nigeria household survey`
Insert cell
d3 = require('d3@5')
Insert cell
d3.range(3,10)

Insert cell
genders = {
return {1: "Male", 2: "Female", "": "Sysmiss"}
}
Insert cell
postHarvestDemographics = rawDemographics.filter(d => d.gender !== 'Sysmiss')
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
rawDemographicsWave3 = {
const data = d3.csvParse(await FileAttachment("sect1_harvestw3.csv").text());
return data.map(mapPostHarvestDemographics(stillInHouseholdProperty.wave3))
.filter(d => stillInHousehold(d) && removeOutliers(d))
}
Insert cell
Insert cell
Insert cell
stillInHouseholdProperty = {return {wave4: "s1q4a", wave2: "s1q14", wave3: 's1q4a', wave1:'s1q19'}}
Insert cell
ruralHousehold.sort((a,b) => a.numberInHousehold - b.numberInHousehold)
Insert cell
Insert cell
Insert cell
stillInHousehold = d => d.stillInHousehold
Insert cell
removeOutliers = d => d.age <= 100
Insert cell
ruralHousehold = householdData.filter(d => d.sector === "Rural")
Insert cell
urbanHousehold = householdData.filter(d => d.sector === "Urban")
Insert cell
sectors = ["", "Urban", "Rural"]
Insert cell
zones = ["", "North Central", "North East", "North West", "South East", "South South", "South West"]
Insert cell
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
histogram(rawDemographicsWave1, {...histogramOptions, xAxisLabel: "Age wave 1"}).width(700).render()
Insert cell
histogram(rawDemographicsWave2, {...histogramOptions, colorField: 'gender', xAxisLabel: "Age wave 2", colorScale: {range: ["red", 'orange']}}).width(700).render()
Insert cell
histogram(rawDemographicsWave3, {...histogramOptions, xAxisLabel: "Age wave 3", markX: 93}).width(700).render()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more