Public
Edited
Nov 10, 2022
Insert cell
Insert cell
import { SankeyChart } from "@d3/sankey"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
DataStudent = FileAttachment("students.csv").csv({ typed: true })
Insert cell
Insert cell
/* cleanedSchool[] = DataStudent.map{func(), row,
return cleanedSchool;
} array.map(function(currentValue, index, arr), thisValue) */
/* data =
let data = [];
obj.map( obj => {

const numKeys = Object.keys.length - offset
})
return data;
} */
Insert cell
Object.values(DataStudent)
Insert cell
Object.keys(DataStudent [0])
Insert cell
Object.entries(DataStudent)
Insert cell
NewDataStudent = {
let data = [];
let numQuestions = Object.keys(DataStudent[0]).length - 1;
//DataStudent.map( student => {
//for ( let counter = 1 ; counter <= numQuestions ; counter++) {
//Some code here
//}
DataStudent.map((students) => {
let entries = Object.entries(students);
entries.map((entry, questionN) => {
if (entry[0] !== "Timestamp" && questionN < numQuestions) {

let source = entry[1]
let target = entries[questionN + 1][1]
//check to see if data contains combination of survey responses
//yes: update the correct element
let result = data.find((element) => {
return (element.source === source && element.target === target)
})
if (result) {
result.value = result.value +1;
}
else {
//no: add response to data
data.push({
source: source,
target: target,
value: 1
});
}
}
});
});
return data;
}
Insert cell
Insert cell
Insert cell
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