Published
Edited
Apr 12, 2018
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
bifurcated = stdlib.bifurcateBy( nutrition, function( x ) { return x.diabetes === 'Yes'; } )
Insert cell
Insert cell
salad_diabetes = bifurcated[ 0 ].map( function( x ) { return parseInt( x.GREENSALADFREQ ); } )
Insert cell
salad_no_diabetes = bifurcated[ 1 ].map( function( x ) { return parseInt( x.GREENSALADFREQ ); } )
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
pvalues = {
var fq = Object.keys( nutrition[ 0 ] ).filter( function( x, i ) { return i > 27; } )
var arr = new Array( fq.length );
for ( var i = 0; i < fq.length; i++ ) {
var diabetes = stdlib.pluck( bifurcated[ 0 ], fq[ i ] ).map( function( x ) { return parseInt( x ) } );
var nodiabetes = stdlib.pluck( bifurcated[ 1 ], fq[ i ] ).map( function( x ) { return parseInt( x ) } );
var out = stdlib.ttest2( diabetes, nodiabetes );
arr[ i ] = out.pValue;
}
return arr.sort();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
plt = {
var x = stdlib.incrspace( 0, 1065, 1 );
var y = x.map( function( x ) { return x * 0.05/1065 } );
return stdlib.plot( [ x, x ],[ y, pvalues ], {
'xLabel': 'k',
'yLabel': 'P_k',
'width': 600,
'xMax': xRange[ 0 ],
'yMax': xRange[ 1 ]
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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