Public
Edited
Dec 13, 2023
Insert cell
Insert cell
Insert cell
Insert cell
usa-cause-age.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
TODO:

- collapse by year
- group by age
- filter out: year, total, age1-19

The *usa-cause-age.csv* dataset contains the fields we need:
- date year/month
- AgeGroup
- AllCause: all deaths for that age group and cause
- Then the number of deaths by cause
Insert cell
rawDataByAge[0]
Insert cell
Insert cell
dataUsa[0]
Insert cell
dataUsa = {
// const filtered = rawDataByAge.filter((e) =>
// stateCodes.includes(e["State Abbreviation"])
// );
const p = rawDataByAge.map((o) => {
const keys = Object.keys(o);
const newO = {};
keys.map((k) => {
if (k === "Date Of Death Year") newO["year"] = o[k];
if (k === "Date Of Death Month") newO["month"] = o[k];
if (k === "AllCause") newO["allCause"] = o[k];
if (k === "AgeGroup") newO["ageGroup"] = o[k];
});
return newO;
});

return p;
}
Insert cell
Plot.plot({
width: 1152,
insetLeft: 20,
insetRight: 60,
marks: [
Plot.frame({ anchor: "bottom" }),
Plot.dot(dataUsa, {
anchor: "bottom",
x: "date",
y: "deaths",
interval: "year",
fill: "#ddd",
stroke: "#000",
strokeWidth: 1
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
rawData = re
Insert cell
stateCodes = baseStates.map(({ Code }) => Code)
Insert cell
import { baseStates } from "@bratter/us-state-metadata"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more