My dataset consists of a csv file containing 5000 rows, with each row having thirty fields representing measurements of different chemical elements.
I aim to parse and visualize this data using D3js. Upon reading the file, I obtain an array of length 5000 where each element is an object holding measurements of various chemical elements. For example, measurements[5].Aluminium
provides the concentration of Aluminium at the fifth measurement.
Instead of individual values, I wish to organize the data into arrays for each element. While achievable through a for-loop, I want to experiment with the map function.
Aluminium = measurements.map(function(row){
return row.Aluminium;
});
The above code successfully creates an array for one element, but I desire a more flexible approach by passing the element name as a parameter.
function selectElement(elementname){
measurements.map(function(row){
return row.elementname;
});
};
Aluminium = selectElement('Aluminium');
Iron = selectElement('Iron');
However, implementing this change has proven challenging, leaving me at a roadblock in my progress.