Public
Edited
Oct 26, 2022
1 fork
26 stars
Insert cell
Insert cell
Insert cell
wb_data = FileAttachment("wb_data.csv").csv({ typed: true })
Insert cell
country_metadata = FileAttachment("country_metadata.csv").csv({ typed: true })
Insert cell
data = aq
.from(wb_data)
.select(aq.not("Series Code", "Country Name"))
.fold(aq.not("Country Code", "Series Name"), { as: ["year"] })
.derive({
series: (d) => aq.op.split(d["Series Name"], " ")[0],
year: (d) => +aq.op.split(d.year, " ")[0]
})
.select(aq.not("Series Name"))
.groupby("Country Code", "year")
.pivot("series", "value")
.join_left(aq.from(country_metadata), ["Country Code", "Code"])
.filter((d) => d.Region)
Insert cell
viewof table = Inputs.table(data)
Insert cell
Plot.plot({
facet: {
data,
x: "Region"
},
marks: [
Plot.dot(data, { x: "GDP", y: "Life", stroke: "Country Code", r: "year" }),
Plot.frame()
],
r: {
domain: d3.extent(data, (d) => d.year),
range: [0, 7]
},
x: {
type: "log"
},
width
})
Insert cell
import { Wrangler, op } from "@observablehq/data-wrangler"
Insert cell
Wrangler(wb_data)
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