Public
Edited
Feb 27, 2023
Fork of PSET 3
1 fork
Insert cell
Insert cell
import { tidy, mutate, arrange, desc } from '@pbeshai/tidyjs'

Insert cell
Insert cell
Insert cell
ACS_NYCHA.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
myACS = tidy(acs_nycha,
mutate({ pUnder15: d => d.pop5t9P + d.pop10t14P + d.popu5P,
p15to24: d => d.pop15t19P + d.pop20t24P,
p25to60: d => d.pop25t29P + d.pop30t34P + d.pop35t39P + d.pop40t44P +d.pop45t49P + d.pop50t54P + d.pop55t59P,
pOver60: d => d.pop60t64P + d.pop65t69P + d.pop70t74P + d.pop75t79P + d.pop80t84P + d.pop85plP,
devCosts: d => Number(d['DEVELOPMENT COST'].replace(/[$,]/g, '')),
amgRent: d => Number(d['AVG MONTHLY GROSS RENT'].replace(/[$,]/g, '')),
unbuiltArea: d=> Number(d['CUBAGE CU FT'].replace(/[$,]/g, '')) - Number(d['BLDG COVERAGE SQ FT'].replace(/[$,]/g, '')),
ages: d=> [d.pUnder15, d.p15to24, d.p25to60, d.pOver60]}
))
Insert cell
Plot.dot(myACS, {
y: "p25to60",
x: "unbuiltArea",
fill: (d) => d['AVG MONTHLY GROSS RENT']
}).plot({
color: { scheme: "reds" }
})
Insert cell
Insert cell
// Your code here

Insert cell
Insert cell
// Your code here

Insert cell
Insert cell
Plot.rect(myACS, Plot.bin({fillOpacity: "count"}, {x: "p25to60", y: "unbuiltArea"})).plot()
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
color: {
scheme: "bupu",

},
marks: [
Plot.rectY(
myACS,
Plot.binX(
{ y: "count" },
{
x: "p15to24",
fill: "BOROUGH",
fillOpacity: 1,
thresholds: 10
}
)
)
]
})
Insert cell
Insert cell
Insert cell
myACS[0].BOROUGH
Insert cell
Plot.plot({
color: {
scheme: "bupu",

},
marks: [
Plot.rectY(
myACS.filter(d=>d.BOROUGH == "BROOKLYN"),
Plot.binX(
{ y: "count" },
{
x: "p15to24",
fill: "BOROUGH",
fillOpacity: 1,
thresholds: 10
}
)
)
]
})
Insert cell
Insert cell

ages = myACS.columns
Insert cell
facetAge = {
const ages = myACS.slice(1); // convert wide data to tidy data
return Object.assign(ages.flatMap(x => myACS.map(d=> [d.pUnder15, d.p15to24, d.p25to60, d.pOver60])))
}
Insert cell
Plot.plot({
x: {insetRight: 10},
y: {grid: true},
color: {
// domain: myACS.ages,
scheme: "spectral"
},
facet: {
data: "ages",
x: "count"
},
marks: [

Plot.barX(myACS, Plot.groupY({x: "count"}, {fy: ages, y: "BOROUGH", fill: "ages"})),

]
})



Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more