Public
Edited
Dec 15, 2023
Insert cell
Insert cell
Insert cell
raw = FileAttachment("Course project peer evaluation form F2023 (Responses) - Copy of Form responses 1 (1).csv").csv()
Insert cell
tidy
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
//convert to tidy data

tidy = {
const tidy = []
for (let row of raw){
const teammateKeys = Object.keys(row).filter(f => f.includes("name"))
for (let teammateKey of teammateKeys){
if(row[teammateKey]) {
const measureNames = buildMeasureNames(teammateKey);
const resolvedMeasures = measureNames.map((measure, i) => [ MEASURES[i], getGrade(row[measure]) ])
const filteredValid = resolvedMeasures.filter(f => f[1] === 0 || !!f[1])

for(let [measure, value] of filteredValid) {
tidy.push({ from: row[YOURNAME], to: row[teammateKey], measure, value })
}
}
}
}
return tidy
}
Insert cell
Object.fromEntries(d3.rollups(tidy, v => +d3.mean(v, d => d.value).toFixed(2), d => d.to).toSorted((a,b)=>d3.ascending(a[0], b[0])))
Insert cell
YOURNAME = "Your name"
Insert cell
MEASURES = unique(raw.columns.filter(f => f.includes("[")).map(m => m.split("[")[0].trim()))
Insert cell
buildMeasureNames = (key) => {
if(key === YOURNAME) return MEASURES.map(m => m + " [You]")
const teammate = "[" + key.replace(" name:", "") + "]";
return MEASURES.map(m => m + " " + teammate)
}
Insert cell
getGrade = (string) => {return GRADES[string] ?? ""}
Insert cell
GRADES = ({
"Outstanding": 1,
"Very good": 0.8,
"Marginal": 0.2,
"Unacceptable": 0,
})
Insert cell
unique = (array) => [...new Set(array)]
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