Public
Edited
Mar 4, 2023
Insert cell
Insert cell
viewof fields = Inputs.checkbox(new Set(trends.map((d) => d.CIPTitle)), {
value: cutlist
})
Insert cell
Insert cell
Insert cell
t = trends
.map((d) => {
d.cutlist = cutlist.includes(d.CIPTitle) ? "cut" : "safe";
return d;
})
.filter((d) => d.majors)
Insert cell
trends
Insert cell
Insert cell
Insert cell
viewof trends3 = await client.table(
`
SELECT * FROM degrees WHERE AWLEVEL=5 AND INSTNM = 'Marymount University' LIMIT 1
`
)
Insert cell
trends2.filter((d) => d.INSTNM == "Marymount University")[0]
Insert cell
JSON.stringify(cutlist).slice(1, -1)
Insert cell
viewof trends2 = await client.table(
`
WITH totals AS (SELECT INSTNM, UNITID, SUM(degrees) totals FROM degrees WHERE AWLEVEL=5 AND year > 2015 AND CARNEGIE IN (21, 22) AND CONTROL = 2 GROUP BY INSTNM, UNITID),
mmount AS (SELECT totals AS mmountotal FROM totals WHERE UNITID = 232706),
compgroup AS (SELECT * FROM totals CROSS JOIN mmount WHERE totals > 3000 AND totals < 3500), --ABS(totals - mmountotal) < 250),
tb AS (SELECT UNITID, CIPTitle, sum(degrees.degrees) AS "majors" FROM degrees WHERE AWLEVEL=5 AND CIPTitle IN (${JSON.stringify(
cutlist
)
.slice(1, -1)
.replaceAll(
'"',
"'"
)}) AND year > 2016 GROUP BY UNITID, CIPTitle ORDER BY majors DESC ),
totals2 AS (SELECT * FROM compgroup CROSS JOIN (SELECT DISTINCT(CIPTitle) FROM tb) t1),
tb1 AS (SELECT *, COALESCE(majors, 0) AS totals, COALESCE(majors/totals, 0) as share FROM tb RIGHT JOIN totals2 USING (UNITID, CIPTitle) ORDER BY share DESC)
SELECT ROW_NUMBER() OVER () as rank, * FROM tb1
`
)
Insert cell
Insert cell
{
const div = DOM.element("div");
div.style = "display: flex; flex-wrap: wrap; flex-direction:row";

for (let cut of cutlist) {
const svg = Plot.plot({
marginLeft: 190,
height: 300,
width: width / 2,
marks: [
Plot.barX(
trends2.filter((d) => d.CIPTitle == cut),
{
y: "INSTNM",
x: "majors",
sort: { y: "x" },
fill: (d) => d.INSTNM == "Marymount University"
}
)
]
});

const holder = DOM.element("div");
const title = html`<h3 style="font-family:sans-serif;margin-bottom:0px;margin-top:10px;margin-left:40px;">${cut}</h3>`;
title.text = cut;
holder.appendChild(title);
holder.appendChild(svg);
div.appendChild(holder);
}
return div;
}
Insert cell
import { client } from "@bmschmidt/duckdb-degrees"
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