Published
Edited
Jun 23, 2020
Insert cell
Insert cell
Insert cell
Insert cell
channels = FileAttachment("channels.json").json()
Insert cell
users = FileAttachment("users.json").json()
Insert cell
messages = FileAttachment("messages.json").json()
Insert cell
Insert cell
messages[22]
Insert cell
Insert cell
Insert cell
{
const result = [];
for(let i = 0; i < users.length; i++){
const u = users[i];
if(u.is_bot){
result.push(u);
}
}
return result;
}
Insert cell
Insert cell
users.filter(u => u.is_bot)
Insert cell
Insert cell
function testIsBot(u){
return u.is_bot;
}
Insert cell
Insert cell
users.filter(testIsBot)
Insert cell
Insert cell
Insert cell
messages.filter(m => m.reactions && m.reactions.length >= 3).length / messages.length
Insert cell
Insert cell
usermetadata = FileAttachment("usermetadata.json").json()
Insert cell
Insert cell
messages2 = messages.map(u => {
const data = usermetadata.find(data => data.userid == u.user);
if(!data) return u;
return {
...u,
kind: data.kind,
isStudent: data.kind.startsWith("ROOT"),
advanced: data.advanced
};
})
Insert cell
messages2[22]
Insert cell
md`リアクションの個数が多いものだけ抜き出す、みたいな処理がしたい`
Insert cell
md`とりあえずリアクションの配列の長さを取得してみる`
Insert cell
messages2[22].reactions.length
Insert cell
md`リアクションのあるメッセージだけ抜き出す`
Insert cell
messages2.filter(m => m.reactions)
Insert cell
md`リアクションが10個以上付いているメッセージだけ抜き出す`
Insert cell
messages2.filter(m => m.reactions).filter(n => n.reactions.length >= 10)
Insert cell
md`この中で、生徒の発言だけ取り出す`
Insert cell
messages2.filter(m => m.reactions).filter(n => n.reactions.length >= 10).filter(s => s.isStudent)
Insert cell
md`なんと、ほとんどの発言(19個中15個)が生徒によるものでした!!!!`
Insert cell
md`advencdの生徒の発言の方がいいねが付きやすい?`
Insert cell
messages2.filter(m => m.reactions).filter(n => n.reactions.length >= 10).filter(s => s.isStudent).filter(a => a.advanced == "TRUE")
Insert cell
md`生徒の発言15個のうち、12個がadvancedの生徒による発言でした`
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