Published
Edited
Apr 27, 2021
2 forks
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
community_data = d3.csvParse(await FileAttachment("communities@4.csv").text(), function(d) {
return {
community: d.community,
community_type: d.community_type,
user_count: d.count,
active_users: d.active,
deleted_users: d.deleted,
suspended_users: d.suspended,
active_users_p: d.active_p,
deleted_users_p: d.deleted_p,
suspended_p: d.suspended_p,
};
});
Insert cell
user_status_data = d3.csvParse(await FileAttachment("user_status.csv").text(), function(d) {
return {
community: d.community,
community_type: d.community_type,
user_status: d.user_status,
value: d.value,
percentage: d.percentage
};
});
Insert cell
promoters = [{active: "846111", deleted: "6206", suspended: "8659"}]
Insert cell
tweet_data = d3.csvParse(await FileAttachment("tweets@1.csv").text(), function(d) {
return {
tweet_id: d.tweet_id,
community: d.user_community,
community_type: d.community_type,
user_account_status: d.user_active_status,
RTs: d.retweet_count,
QTs: d.quote_count,
RTs_community0: d.retweet_count_by_community_0,
QTs_community0: d.quote_count_by_community_0,
RTs_community1: d.retweet_count_by_community_1,
QTs_community1: d.quote_count_by_community_1,
RTs_community2: d.retweet_count_by_community_2,
QTs_community2: d.quote_count_by_community_2,
RTs_community3: d.retweet_count_by_community_3,
QTs_community3: d.quote_count_by_community_3,
RTs_community4: d.retweet_count_by_community_4,
QTs_community4: d.quote_count_by_community_4,
RTs_suspended: d.retweet_count_by_suspended_users,
QTs_suspended: d.quote_count_by_suspended_users,
date: d3.timeParse("%Y_%m")(d.date),
};
});
Insert cell
user_data = d3.csvParse(await FileAttachment("users@1.csv").text(), function(d) {
return {
user_id: d.user_id,
community: d.user_community,
community_type: d.community_type,
user_account_status: d.user_active_status,
RTs: d.retweet_count,
QTs: d.quote_count,
RTs_community0: d.retweet_count_by_community_0,
QTs_community0: d.quote_count_by_community_0,
RTs_community1: d.retweet_count_by_community_1,
QTs_community1: d.quote_count_by_community_1,
RTs_community2: d.retweet_count_by_community_2,
QTs_community2: d.quote_count_by_community_2,
RTs_community3: d.retweet_count_by_community_3,
QTs_community3: d.quote_count_by_community_3,
RTs_community4: d.retweet_count_by_community_4,
QTs_community4: d.quote_count_by_community_4,
RTs_suspended: d.retweet_count_by_suspended_users,
QTs_suspended: d.quote_count_by_suspended_users
};
});
Insert cell
url_data = d3.csvParse(await FileAttachment("urls@1.csv").text(), function(d) {
return {
domain: d.domain,
Tweets: d.tweet_count,
RTs: d.retweet_count_metadata,
QTs: d.quote_count_metadata,
Tweets_community0: d.tweet_count_by_community_0,
RTs_community0: d.retweet_count_by_community_0,
QTs_community0: d.quote_count_by_community_0,
Tweets_community1: d.tweet_count_by_community_1,
RTs_community1: d.retweet_count_by_community_1,
QTs_community1: d.quote_count_by_community_1,
Tweets_community2: d.tweet_count_by_community_2,
RTs_community2: d.retweet_count_by_community_2,
QTs_community2: d.quote_count_by_community_2,
Tweets_community3: d.tweet_count_by_community_3,
RTs_community3: d.retweet_count_by_community_3,
QTs_community3: d.quote_count_by_community_3,
Tweets_community4: d.tweet_count_by_community_4,
RTs_community4: d.retweet_count_by_community_4,
QTs_community4: d.quote_count_by_community_4,
Tweets_suspended: d.tweet_count_by_suspended_users,
RTs_suspended: d.retweet_count_by_suspended_users,
QTs_suspended: d.quote_count_by_suspended_users,
Tweets_promoters: d.tweet_promoters,
RTs_promoters: d.retweet_promoters,
QTs_promoters: d.quote_promoters,
};
});
Insert cell
Insert cell
Insert cell
Insert cell
detractors_sorted = url_d_data.sort(function (a, b) {
var detractors_sorted = b.RTs_community0 - a.RTs_community0
return detractors_sorted
});
Insert cell
detractors_top10 = detractors_sorted.slice(0,10)
Insert cell
promoters_sorted = url_p_data.sort(function (a, b) {
var promoters_sorted = b.RTs_promoters - a.RTs_promoters
return promoters_sorted;
});
Insert cell
promoters_top10 = promoters_sorted.slice(0,10)
Insert cell
all_url_sorted = url_data.sort(function (a, b) {
return b.RTs - a.RTs;
});
Insert cell
all_url_top20 = all_url_sorted.slice(0,20)
Insert cell
Insert cell
import {vl} from "@vega/vega-lite-api-v5"
Insert cell
d3 = require("d3@6")
Insert cell
import {printTable} from '@uwdata/data-utilities'
Insert cell
import {toc} from "@harrystevens/toc"
Insert cell
vegaEmbed = require("vega-embed@5")
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