Published
Edited
Jun 1, 2021
3 stars
Insert cell
Insert cell
Insert cell
aq.table({ x: [1, 2, 3] })
.rollup({ value: op.every('x') })
.view()
Insert cell
aq.table({ x: [1, null, 2] })
.rollup({ value: op.every('x') })
.view()
Insert cell
Insert cell
every = ({
create: () => ({
init: (state) => state.every = 0, // initialize state
add: (state, value) => { if (value) state.every += 1; },
rem: (state, value) => { if (value) state.every -= 1; },
value: (state) => state.count === state.every
}),
param: [1, 0] // 1 column input, 0 extra parameters
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
aq.table({ a: [1, 2, 2, 3, 4, 5], b: [9, 8, 8, 7, 6, 5] })
.orderby('a').derive({ ra: op.avg_rank() })
.orderby('b').derive({ rb: op.avg_rank() })
.rollup({ rho: d => op.corr(d.ra, d.rb) })
.view()
Insert cell
Insert cell
aq.table({ a: [1, 2, 2, 3, 4, 5], b: [9, 8, 8, 7, 6, 5] })
.rollup({ rho: d => op.corr_rank(d.a, d.b) })
.view()
Insert cell
Insert cell
corr_rank = ({
create: () => ({
init: (state) => state.values = true, // request field value collection
add: () => {}, // no-op, let field values be added to list
rem: () => {}, // no-op, let field values be removed from list
value: (state) => {
return aq.from(state.list.values())
.orderby('0').derive({ ra: aq.op.avg_rank() })
.orderby('1').derive({ rb: aq.op.avg_rank() })
.rollup({ rho: d => aq.op.corr(d.ra, d.rb) })
.get('rho');
}
}),
param: [2, 0] // 2 field inputs, 0 extra parameters
})
Insert cell
Insert cell
Insert cell
// register aggregate functions with arquero, return op namespace
// use { override: true } to avoid complaints if we update our function definitions
op = (
aq.addAggregateFunction('every', every, { override: true }),
aq.addAggregateFunction('corr_rank', corr_rank, { override: true }),
aq.op
)
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