Public
Edited
Mar 7, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
points = eng_comp[1].filter(d => d.year === scrubberYear).map(d => {
return {
name: d.institution,
key: d.field,
raw: d.expenditures,
// value: d.expenditures / d3.max(eng_comp[1].filter(d => d.year === scrubberYear), d => d.expenditures),
value: d.expenditures / d3.max(eng_comp[1], d => d.expenditures),
};
});
Insert cell
utk_points = {
const utk_eng_data = eng_data.find(d => d[0] === "UTK")[1];
// return utk_eng_data;

const field_max = new Map(d3.groups(utk_eng_data, d => d.field).map(d => ([d[0], d3.max(d[1], t => t.expenditures)])))
// return field_max;

return utk_eng_data.filter(d => d.year === scrubberYear).map(d => {
return {
name: d.institution,
key: d.field,
raw: d.expenditures,
max: field_max.get(d.field),
value: field_max.get(d.field) !== 0 ? d.expenditures / field_max.get(d.field) : 0,
};
});
}
Insert cell
points_2 = d3.merge(eng_data.map((univ,i_univ) => {
const univ_data = univ[1].filter(d => d.year === scrubberYear);
return univ_data.map(d => {
return {
name: univ[0],
key: d.field,
raw: d.expenditures,
// fx: i_univ % 3,
fx: (i_univ) % 4,
fy: Math.floor((i_univ) / 4),
// value: d.expenditures / d3.max(univ_data, d => d.expenditures),
value: d.expenditures / max_expenditure,
};
});
}));
Insert cell
eng_points = {
const year_eng_data = eng_data.map(d => ([d[0], d[1].filter(v => v.year === scrubberYear)]));
// return year_eng_data;

const field_max_data = new Map(d3.groups(d3.merge(year_eng_data.map(d => d[1])), d => d.field).map(d => ([d[0], d3.max(d[1], t => t.expenditures)])));
// return field_max_data;

return d3.merge(year_eng_data.map((d,i) => {
return d[1].map(v => {
return {
name: d[0],
key: v.field,
raw: v.expenditures,
fx: (i) % 4,
fy: Math.floor((i) / 4),
max: field_max_data.get(v.field),
value: field_max_data.get(v.field) > 0 ? v.expenditures / field_max_data.get(v.field) : 0,
};
});
}));
}
Insert cell
max_expenditure = d3.max(d3.merge(eng_data.map(d => d[1])).filter(d => d.year === scrubberYear), d => d.expenditures)
Insert cell
d3.merge(eng_data.map(d => d[1])).filter(d => d.year === scrubberYear)
Insert cell
longitude = d3.scalePoint(new Set(Plot.valueof(utk_points, "key")), [180, -180]).padding(0.5).align(1)
Insert cell
longitude2 = d3.scalePoint(new Set(Plot.valueof(eng_points/*points_2*/, "key")), [180, -180]).padding(0.5).align(1)
Insert cell
lsu_utk_comp = d3.merge(eng_comp).filter(d => d.year === 2022)
Insert cell
utk_expenditures = {
const raw = await FileAttachment("utk_expenditures@3.csv").csv({typed: true});
const years = Object.keys(raw[0]).filter(d => +d).sort(d3.ascending);
const data = d3.merge(raw.map(d => {
return years.map(y => {
return {
institution: "UTK",
sector: d.Sector,
field_group: d.Field_Group,
field: d.Field,
date: new Date(y, 0, 1),
year: +y,
expenditures: d[y],
};
});
}));
// return data;
return data.filter(d => d.field !== null)
}
Insert cell
lsu_expenditures = {
const raw = await FileAttachment("lsu_expenditures@1.csv").csv({typed: true});
const years = Object.keys(raw[0]).filter(d => +d).sort(d3.ascending);
const data = d3.merge(raw.map(d => {
return years.map(y => {
return {
institution: "LSU",
sector: d.Sector,
field_group: d.Field_Group,
field: d.Field,
date: new Date(y, 0, 1),
year: +y,
expenditures: d[y],
};
});
}));
// return data;
return data.filter(d => d.field !== null)
}
Insert cell
vandy_expenditures = {
const raw = await FileAttachment("vandy_expenditures.csv").csv({typed: true});
const years = Object.keys(raw[0]).filter(d => +d).sort(d3.ascending);

return d3.merge(raw.map(d => {
return years.map(y => {
return {
institution: "Vanderbilt",
field: d.Field.trim(),
date: new Date(y, 0, 1),
year: +y,
expenditures: d[y],
};
});
}));
}
Insert cell
auburn_expenditures = {
const raw = await FileAttachment("auburn_expenditures.csv").csv({typed: true});
const years = Object.keys(raw[0]).filter(d => +d).sort(d3.ascending);

return d3.merge(raw.map(d => {
return years.map(y => {
return {
institution: "Auburn",
field: d.Field.trim(),
date: new Date(y, 0, 1),
year: +y,
expenditures: d[y],
};
});
}));
}
Insert cell
ark_expenditures = {
const raw = await FileAttachment("ark_expenditures.csv").csv({typed: true});
const years = Object.keys(raw[0]).filter(d => +d).sort(d3.ascending);
return d3.merge(raw.map(d => {
return years.map(y => {
return {
institution: "Arkansas",
field: d.Field.trim(),
date: new Date(y, 0, 1),
year: +y,
expenditures: d[y],
};
});
}));
}
Insert cell
uga_expenditures = {
const raw = await FileAttachment("uga_expenditures@1.csv").csv({typed: true});
const years = Object.keys(raw[0]).filter(d => +d).sort(d3.ascending);

return d3.merge(raw.map(d => {
return years.map(y => {
return {
institution: "UGA",
field: d.Field.trim(),
date: new Date(y, 0, 1),
year: +y,
expenditures: d[y],
};
});
}));
}
Insert cell
uk_expenditures = {
const raw = await FileAttachment("uk_expenditures.csv").csv({typed: true});
const years = Object.keys(raw[0]).filter(d => +d).sort(d3.ascending);

return d3.merge(raw.map(d => {
return years.map(y => {
return {
institution: "UK",
field: d.Field.trim(),
date: new Date(y, 0, 1),
year: +y,
expenditures: d[y],
};
});
}));
}
Insert cell
msu_expenditures = {
const raw = await FileAttachment("msu_expenditures.csv").csv({typed: true});
const years = Object.keys(raw[0]).filter(d => +d).sort(d3.ascending);

return d3.merge(raw.map(d => {
return years.map(y => {
return {
institution: "MSU",
field: d.Field.trim(),
date: new Date(y, 0, 1),
year: +y,
expenditures: d[y],
};
});
}));
}
Insert cell
eng_data = {
return [
["UTK", utk_expenditures.filter(d => d.sector === "Engineering")],
["LSU", lsu_expenditures.filter(d => d.sector === "Engineering")],
["MSU", msu_expenditures],
["UK", uk_expenditures],
["UGA", uga_expenditures],
["Auburn", auburn_expenditures],
["Vandy", vandy_expenditures],
["Arkansas", ark_expenditures]
];
}
Insert cell
eng_comp = {
return [lsu_expenditures.filter(d => d.sector === "Engineering"), utk_expenditures.filter(d => d.sector === "Engineering")];

// return d3.merge([lsu_expenditures.filter(d => d.sector === "Engineering"), utk_expenditures.filter(d => d.sector === "Engineering")]);
}
Insert cell
import {Scrubber} from "@mbostock/scrubber"
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