Published
Edited
Sep 12, 2022
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
`23.1001, 23.1304
51.1699, 51.3899
06.1499, 52.1499
23.0401, 23.1304

)
`
Insert cell
database.table(
`SELECT SUM(degrees) d, CIPCODE, MIN(year), MAX(year) FROM labeled WHERE AWLEVEL=5 AND Discipline IS NULL AND year > 2003 GROUP BY CIPCODE ORDER BY d DESC`
)
Insert cell
Insert cell
embed({
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
width: width,
height: 500,
projection: {
type: "albersUsa"
},
layer: [
{
data: {
url: "https://cdn.jsdelivr.net/npm/us-atlas@3/counties-10m.json",
format: {
type: "topojson",
feature: "states"
}
},
mark: {
type: "geoshape",
fill: "lightgray",
stroke: "white"
}
},
{
data: {
values: geo.filter((d) => d.year == year && d.LONGITUD)
},
encoding: {
longitude: {
field: "LONGITUD",
type: "quantitative"
},
latitude: {
field: "LATITUDE",
type: "quantitative"
}
},
layer: [
{
mark: {
type: "circle",
tooltip: ["INSTNM"]
},
encoding: {
size: {
field: "degrees",
type: "quantitative"
}
}
}
/* {
mark: {
type: "text",
dy: -10
},
encoding: {
text: { field: "city", type: "nominal" }
}
} */
]
}
]
})
Insert cell
viewof geo = database.table(
`
SELECT INSTNM::STRING INSTNM, LONGITUD, LATITUDE, SUM(degrees)::FLOAT degrees, year FROM labeled WHERE AWLEVEL = 5 AND MAJORNUM = 1 AND DISCIPLINE = 'History' AND STABBR != 'PR' GROUP BY ALL
`
)
Insert cell
characteristics = FileAttachment("ic.parquet")
Insert cell
taxonomy = FileAttachment("taxonomy.parquet")
Insert cell
cipsxwalk = FileAttachment("cipsxwalk.parquet")
Insert cell
degrees = FileAttachment("degrees.parquet")
Insert cell
database = {
const db = await DuckDBClient.of({
ciplabels,
degrees,
cipsxwalk,
taxonomy,
characteristics
});
await db.query(`CREATE OR REPLACE view labeled AS SELECT * FROM degrees LEFT JOIN cipsxwalk USING (CIPCODE)
LEFT JOIN ciplabels USING (CIP2020) LEFT JOIN taxonomy USING (CIP2020)
LEFT JOIN characteristics USING (UNITID)
`);
return db;
}
Insert cell
database.table("SELECT year from labeled LIMIT 10").then((d) => d.value)
Insert cell
embed = require("vega-embed")
Insert cell
ciplabels = FileAttachment("ciplabels.parquet")
Insert cell
import { DuckDBClient } from "@cmudig/duckdb"
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