Type Table, then Shift-Enter. Ctrl-space for more options.
// Add your code here to do the wrangling steps above!
penguinData
.map((d)=>({
species:d.species,
massKilograms:d.body_mass_g/1000,
billRatio:d.culmen_length_mm/d.culmen_depth_mm
}))
.filter((d)=>d.billRatio>3.5)
penguinData
Type Table, then Shift-Enter. Ctrl-space for more options.
// Find the minimum culmen length in penguinData:
d3.min(penguinData,(d)=>d.culmen_length_mm)
// Alternatively:
d3.mean(penguinData.map((d)=>d.body_mass_g))
// 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)
// Group penguinData by species (store Map as groupSpecies): group value by key, identify unique in column and group object by group, return Map data structure (has key:value pairs like object, but key can be things other than string, iterable, remember element insertion order, and tell you size/ key:valu pairs)
groupSpecies=d3.group(penguinData,d=>d.species)
// Then get just the Adelies:
//Map data structure is good to easily get specific arrays with just the Key with ".get", basically slice up data for analysis
groupSpecies.get("Adelie")
// Group penguinData by species and island (store as groupSpeciesIsland): you can group with multiple conditions
groupSpeciesIsland=d3.group(
penguinData,
(d)=>d.species,
(d)=>d.island
)
// Get observations for Adelie penguins on Dream Island: get adelie specie just for dream island, get subset of subset, good for digging into specific groups in data
groupSpeciesIsland.get("Adelie").get("Dream")
//d3.map(penguinData)
// mean of mass for all pengui together
d3.mean(penguinData.map(d=>d.body_mass_g),d=>d)
d3.mean(penguinData,d=>d.body_mass_g)
// Find the mean body mass by penguin species:
d3.rollup(
penguinData,
(v)=>d3.mean(v,(d)=>d.body_mass_g),
(d,i)=>d.species
)
// Find the mean flipper length by penguin species and sex: get transformed value with more than 1 grouping keys
d3.rollup(
penguinData,
(v)=>d3.mean(v,(d)=>d.flipper_length_mm),
(d)=>d.species,
(d)=>d.sex
)
arrayOfArrays=[
[1,2],
[3,4]
]
//transfer the values into objects, and make the bigger category of object the key
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.