// Add your code here to do the wrangling steps above!
penguinData.map(d=>({speices:d.species,
massKilograms:d.body_mass_g/1000,
billRatio:d.culmen_length_mm/d.culmen_depth_mm}))
.filter(d=>d.billRation>3.5)// iterates over each object, d, returning a new object with the following keys
// Find the minimum culmen length in penguinData:
d3.min(penguinData,d=>d.culmen_length_mm)
// Find the range of culmen lengths in penguinData: d3.min(penguinData, d => d.culmen_length_mm)
d3.extent(penguinData,d=>d.culmen_length_mm)// note its not "range"
// Mean of all body mass (grams) values in penguinData:
d3.mean(penguinData,d=>d.body_mass_g)
// Alternatively:
d3.mean(penguinData.map((d)=>d.body_mass_g))// you can provide an array of values as well, using this syntax
// Standard deviation of culmen depth:
d3.deviation(penguinData,(d)=>d.culmen_depth_mm)
// Count of flipper length values:
d3.count(penguinData,d=>d.flipper_length_mm)
penguinData
Type Table, then Shift-Enter. Ctrl-space for more options.
// Group penguinData by species (store Map as groupSpecies):
groupSpecies=d3.group(penguinData,d=>d.species)// this creates a map with 3 key value pairs: species is the key and value is how many objects are in it
// Then get just the Adelies:
groupSpecies.get("Adelie")// only need to give it the key, returns array
// Group penguinData by species and island (store as groupSpeciesIsland):
groupSpeciesIsland=d3.group(penguinData,
d=>d.species,
d=>d.island)
// Get observations for Adelie penguins on Dream Island:
groupSpeciesIsland.get("Adelie").get("Dream")// get an array of objects on dream island. really cool way to create subsets
// Find the mean body mass by penguin species:
d3.rollup(penguinData,v=>d3.mean(v,d=>d.body_mass_g),d=>d.species)// the last part of this is the species
// Find the mean flipper length by penguin species and sex:
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.