{"id":22966636,"url":"https://github.com/favstats/ic2s2_conf_network","last_synced_at":"2026-01-16T01:40:37.033Z","repository":{"id":108350733,"uuid":"197986984","full_name":"favstats/ic2s2_conf_network","owner":"favstats","description":"This is a short notebook outlining the code used to scrape tweets related to the IC2S2 conference in Amsterdam.","archived":false,"fork":false,"pushed_at":"2019-07-20T22:39:15.000Z","size":2425,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-07T19:36:12.865Z","etag":null,"topics":["computational-social-science","network-analysis","rstats","twitter"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/favstats.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-20T22:30:19.000Z","updated_at":"2019-11-12T21:33:33.000Z","dependencies_parsed_at":"2023-04-18T19:46:44.915Z","dependency_job_id":null,"html_url":"https://github.com/favstats/ic2s2_conf_network","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fic2s2_conf_network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fic2s2_conf_network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fic2s2_conf_network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fic2s2_conf_network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/favstats","download_url":"https://codeload.github.com/favstats/ic2s2_conf_network/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246758372,"owners_count":20828919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computational-social-science","network-analysis","rstats","twitter"],"created_at":"2024-12-14T20:44:54.445Z","updated_at":"2026-01-16T01:40:37.027Z","avatar_url":"https://github.com/favstats.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"IC2S2 Twitter Analysis\n================\nFabio\n2019-07-21\n\nThis is a short notebook outlining the code used to scrape tweets\nrelated to the IC2S2 conference in Amsterdam.\n\n## Packages\n\nLoad the necessary packages\n\n``` r\n# install pacman once if not avaible on your machine\n# install.packages(\"pacman\")\n\npacman::p_load(tidyverse, rtweet, ggraph, igraph, tidygraph)\n```\n\n## Get Data\n\nCall Twitter API. If you want to get data yourself you have to register\nwith a free account where you get your personal access point to Twitter.\nCheck out [`rtweet`](https://github.com/mkearney/rtweet/) and follow the\ninstructions.\n\n``` r\n# twitter_token \u003c- readRDS(\"twitter_token.rds\")\n\nrt \u003c- search_tweets(\n  \"#ic2s2 OR #IC2S2\", n = 5000, include_rts = T, retryonratelimit = T\n)\n\nsave(rt, file = \"data/rt.Rdata\")\n```\n\nLets first look at the data structure and column names. Twitter returns\nover 1,200 unique tweets.\n\n``` r\nload(\"data/rt.Rdata\")\n\nrt %\u003e% glimpse # the same as str, returns a df overview\n```\n\n    ## Observations: 2,438\n    ## Variables: 88\n    ## $ user_id                 \u003cchr\u003e \"375162961\", \"101206764\", \"1374422898\", …\n    ## $ status_id               \u003cchr\u003e \"1152701093530542080\", \"1152701045413490…\n    ## $ created_at              \u003cdttm\u003e 2019-07-20 22:05:31, 2019-07-20 22:05:2…\n    ## $ screen_name             \u003cchr\u003e \"TyphonBaalAmmon\", \"andy_nobes\", \"tendon…\n    ## $ text                    \u003cchr\u003e \"Duncan Watts - \\\"For 20 years I thought…\n    ## $ source                  \u003cchr\u003e \"Twitter Web App\", \"Twitter for Android\"…\n    ## $ display_text_width      \u003cdbl\u003e 140, 140, 140, 140, 140, 140, 140, 140, …\n    ## $ reply_to_status_id      \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ reply_to_user_id        \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ reply_to_screen_name    \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ is_quote                \u003clgl\u003e FALSE, FALSE, FALSE, FALSE, FALSE, FALSE…\n    ## $ is_retweet              \u003clgl\u003e TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE…\n    ## $ favorite_count          \u003cint\u003e 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 0…\n    ## $ retweet_count           \u003cint\u003e 595, 595, 595, 595, 595, 595, 595, 595, …\n    ## $ hashtags                \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ symbols                 \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ urls_url                \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ urls_t.co               \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ urls_expanded_url       \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ media_url               \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ media_t.co              \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ media_expanded_url      \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ media_type              \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ ext_media_url           \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ ext_media_t.co          \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ ext_media_expanded_url  \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…\n    ## $ ext_media_type          \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ mentions_user_id        \u003clist\u003e [\"1907378006\", \"1907378006\", \"190737800…\n    ## $ mentions_screen_name    \u003clist\u003e [\"g_r_richardson\", \"g_r_richardson\", \"g…\n    ## $ lang                    \u003cchr\u003e \"en\", \"en\", \"en\", \"en\", \"en\", \"en\", \"en\"…\n    ## $ quoted_status_id        \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_text             \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_created_at       \u003cdttm\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…\n    ## $ quoted_source           \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_favorite_count   \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_retweet_count    \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_user_id          \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_screen_name      \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_name             \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_followers_count  \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_friends_count    \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_statuses_count   \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_location         \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_description      \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ quoted_verified         \u003clgl\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ retweet_status_id       \u003cchr\u003e \"1152197162350067714\", \"1152197162350067…\n    ## $ retweet_text            \u003cchr\u003e \"Duncan Watts - \\\"For 20 years I thought…\n    ## $ retweet_created_at      \u003cdttm\u003e 2019-07-19 12:43:04, 2019-07-19 12:43:0…\n    ## $ retweet_source          \u003cchr\u003e \"Twitter for Android\", \"Twitter for Andr…\n    ## $ retweet_favorite_count  \u003cint\u003e 2194, 2194, 2194, 2194, 2194, 2194, 2194…\n    ## $ retweet_retweet_count   \u003cint\u003e 595, 595, 595, 595, 595, 595, 595, 595, …\n    ## $ retweet_user_id         \u003cchr\u003e \"1907378006\", \"1907378006\", \"1907378006\"…\n    ## $ retweet_screen_name     \u003cchr\u003e \"g_r_richardson\", \"g_r_richardson\", \"g_r…\n    ## $ retweet_name            \u003cchr\u003e \"George Richardson\", \"George Richardson\"…\n    ## $ retweet_followers_count \u003cint\u003e 621, 621, 621, 621, 621, 621, 621, 621, …\n    ## $ retweet_friends_count   \u003cint\u003e 1114, 1114, 1114, 1114, 1114, 1114, 1114…\n    ## $ retweet_statuses_count  \u003cint\u003e 924, 924, 924, 924, 924, 924, 924, 924, …\n    ## $ retweet_location        \u003cchr\u003e \"London\", \"London\", \"London\", \"London\", …\n    ## $ retweet_description     \u003cchr\u003e \"Mapping innovation @nesta_uk. Podcast c…\n    ## $ retweet_verified        \u003clgl\u003e FALSE, FALSE, FALSE, FALSE, FALSE, FALSE…\n    ## $ place_url               \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ place_name              \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ place_full_name         \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ place_type              \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ country                 \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ country_code            \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ geo_coords              \u003clist\u003e [\u003cNA, NA\u003e, \u003cNA, NA\u003e, \u003cNA, NA\u003e, \u003cNA, NA\u003e…\n    ## $ coords_coords           \u003clist\u003e [\u003cNA, NA\u003e, \u003cNA, NA\u003e, \u003cNA, NA\u003e, \u003cNA, NA\u003e…\n    ## $ bbox_coords             \u003clist\u003e [\u003cNA, NA, NA, NA, NA, NA, NA, NA\u003e, \u003cNA,…\n    ## $ status_url              \u003cchr\u003e \"https://twitter.com/TyphonBaalAmmon/sta…\n    ## $ name                    \u003cchr\u003e \"Monsieur Teubax loves oud and Madame Te…\n    ## $ location                \u003cchr\u003e \"\", \"Didcot | Oxford | beyond...\", \"Univ…\n    ## $ description             \u003cchr\u003e \"Sur ce compte : \u003cU+672C\u003e\u003cU+97F3\u003e, sciences du langage…\n    ## $ url                     \u003cchr\u003e NA, \"https://t.co/3Zfu6bskGd\", \"https://…\n    ## $ protected               \u003clgl\u003e FALSE, FALSE, FALSE, FALSE, FALSE, FALSE…\n    ## $ followers_count         \u003cint\u003e 1335, 1716, 5227, 1834, 661, 1780, 7, 18…\n    ## $ friends_count           \u003cint\u003e 829, 3455, 273, 1047, 550, 675, 290, 171…\n    ## $ listed_count            \u003cint\u003e 74, 49, 77, 33, 6, 31, 0, 180, 2, 0, 2, …\n    ## $ statuses_count          \u003cint\u003e 147013, 7475, 4572, 13145, 2465, 4755, 6…\n    ## $ favourites_count        \u003cint\u003e 78258, 12181, 2613, 5123, 3543, 4604, 30…\n    ## $ account_created_at      \u003cdttm\u003e 2011-09-17 16:26:35, 2010-01-02 12:07:2…\n    ## $ verified                \u003clgl\u003e FALSE, FALSE, FALSE, FALSE, FALSE, FALSE…\n    ## $ profile_url             \u003cchr\u003e NA, \"https://t.co/3Zfu6bskGd\", \"https://…\n    ## $ profile_expanded_url    \u003cchr\u003e NA, \"https://www.linkedin.com/in/andynob…\n    ## $ account_lang            \u003clgl\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …\n    ## $ profile_banner_url      \u003cchr\u003e \"https://pbs.twimg.com/profile_banners/3…\n    ## $ profile_background_url  \u003cchr\u003e \"http://abs.twimg.com/images/themes/them…\n    ## $ profile_image_url       \u003cchr\u003e \"http://pbs.twimg.com/profile_images/111…\n\nThe top ten retweeted tweets.\n\n``` r\n# load(\"rt.Rdata\")\nrt %\u003e% \n  filter(!is_retweet) %\u003e% \n  select(screen_name, text, retweet_count) %\u003e% \n  filter(!str_detect(text, \"^RT\")) %\u003e% \n  mutate(text = str_replace_all(text, \"\\\\\\n\", \" \")) %\u003e% \n  arrange(desc(retweet_count)) %\u003e% \n  top_n(n = 10) %\u003e% \n  knitr::kable(., format = \"markdown\")\n```\n\n| screen\\_name     | text                                                                                                                                                                                                                                                                                                                   | retweet\\_count |\n| :--------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------: |\n| g\\_r\\_richardson | Duncan Watts - “For 20 years I thought my job was as a basic scientist. Publish papers and throw them over the wall for someone else to apply. I now realise that there’s no one on the other side of the wall. Just a huge pile of papers that we’ve all thrown over.” \\#IC2S2                                        |            595 |\n| franktakes       | The scientific discipline migration network of 480 participants @IC2S2 2019 conference on computational social science @UvA\\_Amsterdam, based on links (original-\\\u003ecurrent) discipline, as entered upon registration. Size = weighted indegree. Color = weighted outdegree. \\#IC2S2 \u003chttps://t.co/0pmLwttfWp\u003e          |             48 |\n| dashunwang       | special delivery for \\#IC2S2 - our latest in Nature Human Behavior: \u003chttps://t.co/l1EYiHItNm\u003e Five years in the making. Accompanied by my essay in @HarvardBiz: \u003chttps://t.co/EkZj238lZw\u003e Findings may be relevant to a range of scholars, CSS, diffusion, \\#ScienceOfScience thread \\[1/n\\] \u003chttps://t.co/h7LbpTXVBU\u003e |             24 |\n| RebekahKTromble  | 🚨🚨Hey, \\#IC2S2. I’m looking for 2-3 postdocs for 2 projects at George Washington U. 1st is Twitter health metrics, primarily NLP. 2nd is mis/disinfo, comp methods wide ranging. Both start ASAP this fall. My DMs are temp open. Hit me up if you’d like to chat on Fri or Sat\\!🚨🚨 \u003chttps://t.co/NZcGxwYqcq\u003e          |             22 |\n| IC2S2            | All \\#IC2S2 keynote talks will be livestreamed. Follow them on the website: \u003chttps://t.co/DXh5wjzKD4\u003e                                                                                                                                                                                                                  |             21 |\n| MartonKarsai     | My habilitation thesis on “Computational Human Dynamics” is finally online. Shoot me with questions if you are at \\#IC2S2. \u003chttps://t.co/47Y7DPZ2uA\u003e \u003chttps://t.co/vxiLP4babR\u003e                                                                                                                                         |             19 |\n| computermacgyve  | Super-excited to share a preprint on the different types of errors that we can encounter when using social media data to make inferences about offline populations. \u003chttps://t.co/8DjtBiQ6pR\u003e \\#IC2S2 by Sen, @ffloeck @kwelle @berndweiss \u0026 @clauwa                                                                   |             15 |\n| CNicolaides      | If you are at @IC2S2 and you are interested in an open opportunity of a fully funded PhD studentship on social influence and habit formation in exercise under @H2020Rais, please send me a message or just stop by and talk to me :) \\#IC2S2 \u003chttps://t.co/GGBQM2bcXl\u003e                                                |             15 |\n| talalrahwan      | Great talks and amazing research at @IC2S2 Amsterdam\\! For those interested, there is a \\#postdoc opportunity in my group @NYUAD in Data Science \u0026 Computational Social Science. (Link: \u003chttps://t.co/ny4H2pH9Fj\u003e). \\#IC2S2 \\#SpreadtheWord \\#ComputationalSocialScience \\#CompetitiveSalary                           |             15 |\n| yelenamejova     | Divided we fall: gun control controversy in US shows clear separation between the two sides on Twitter @IC2S2 \\#IC2S2 @gdfm7 @JisunAn @haewoon @ISI\\_Fondazione @QatarComputing \\#guns \\#nra \\#computationalsocialscience \\#socialscience \u003chttps://t.co/6WUtfFNwuF\u003e                                                    |             14 |\n\n## Timeline\n\nWhat was the best time to tweet?\n\n``` r\nrt %\u003e%\n  ## parse date format\n  mutate(created_at = lubridate::as_datetime(created_at, \"Europe/Germany\")) %\u003e% \n  mutate(\n    cdate = created_at %\u003e% \n      str_extract(\"\\\\d{4}-\\\\d{2}-\\\\d{2}\") %\u003e% \n      lubridate::ymd(),\n    hour = lubridate::hour(created_at)\n  ) %\u003e% #select(created_at)\n  ## select relevant time period\n  filter(cdate \u003e= as.Date(\"2019-07-17\") \u0026 cdate \u003c= as.Date(\"2019-07-20\")) %\u003e% \n  ## count tweet per and and hour\n  group_by(cdate, hour) %\u003e%\n  tally %\u003e%\n  ungroup %\u003e%\n  ggplot(aes(hour, n)) +\n  geom_line() +\n  ## split the visualization \n  facet_wrap(~cdate, ncol = 1) +\n  ggthemes::theme_hc() +\n  scale_x_continuous(labels =  seq(5, 24, 3), breaks = seq(5, 24, 3)) +\n  # scale_y_continuous(labels = seq(0, 60, 20), \n                     # breaks = seq(0, 60, 20), \n                     # minor_breaks = seq(0, 60, 20)) +\n  ggtitle(\"Number of Tweets by Hour of the Day mentioning #ic2s2\") +\n  xlab(\"Hour of the Day\") +\n  ylab(\"Number of Tweets\")\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-5-1.png)\u003c!-- --\u003e\n\n## Retweet Network\n\n``` r\nrt_graph \u003c- rt %\u003e% \n  ## select relevant variables\n  dplyr::select(screen_name, retweet_screen_name) %\u003e% \n  ## unnest list of mentions_screen_name\n  unnest %\u003e% \n  ## count the number of coocurences\n  group_by(screen_name, retweet_screen_name) %\u003e% \n  tally(sort = T) %\u003e%\n  ungroup %\u003e% \n  ## drop missing values\n  drop_na %\u003e% \n  ## filter those coocurences that appear at least 2 times\n  filter(n \u003e 1) %\u003e% \n  ## transforming the dataframe to a graph object\n  as_tbl_graph() %\u003e% \n  ## calculating node centrality\n  mutate(centrality = centrality_degree(mode = 'in'))\n\nrt_graph %\u003e% \n  ## create graph layout\n  ggraph(layout = \"kk\") + \n  ## define edge aestetics\n  geom_edge_fan(aes(alpha = n, edge_width = n, color = n)) + \n  ## scale down link saturation\n  scale_edge_alpha(range = c(.5, .9)) +\n  ## define note size param\n  scale_edge_color_gradient(low = \"gray50\", high = \"#1874CD\") +\n  geom_node_point(aes(size = centrality), color = \"gray30\") +\n  ## equal width and height\n  coord_fixed() +\n  ## plain theme\n  theme_void() +\n  ## title\n  ggtitle(\"#ic2s2 Retweet Network\")\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-6-1.png)\u003c!-- --\u003e\n\n``` r\nrt_graph %\u003e% \n  ## create graph layout\n  ggraph(layout = \"kk\") + \n  ## define edge aestetics\n  geom_edge_fan(aes(alpha = n, edge_width = n, color = n)) + \n  ## scale down link saturation\n  scale_edge_alpha(range = c(.5, .9)) +\n  ## define note size param\n  scale_edge_color_gradient(low = \"gray50\", high = \"#1874CD\") +\n  geom_node_point(aes(size = centrality), color = \"gray30\") +\n  ## define node labels\n  geom_node_text(aes(label = name), repel = T, fontface = \"bold\") +\n  ## equal width and height\n  coord_fixed() +\n  ## plain theme\n  theme_void() +\n  ## title\n  ggtitle(\"#ic2s2 Retweet Network\") +\n  theme(plot.title = element_text(size = 20, hjust = 0.5))\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-6-2.png)\u003c!-- --\u003e\n\n``` r\nrt_graph %\u003e% \n  ## create graph layout\n  ggraph(layout = \"circle\") + \n  ## define edge aestetics\n  geom_edge_fan(aes(alpha = n, edge_width = n, color = n)) + \n  ## scale down link saturation\n  scale_edge_alpha(range = c(.5, .9)) +\n  ## define note size param\n  scale_edge_color_gradient(low = \"gray50\", high = \"#1874CD\") +\n  geom_node_point(aes(size = centrality), color = \"gray30\") +\n  ## define node labels\n  geom_node_text(aes(label = name), repel = F, fontface = \"bold\") +\n  ## equal width and height\n  coord_fixed() +\n  ## plain theme\n  theme_void() +\n  ## title\n  ggtitle(\"#ic2s2 Retweet Network\")\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-6-3.png)\u003c!-- --\u003e\n\n## Mentions Network\n\n``` r\nrt_graph \u003c- rt %\u003e% \n  ## remove retweets\n  filter(!is_retweet) %\u003e% \n  ## select relevant variables\n  dplyr::select(screen_name, mentions_screen_name) %\u003e% \n  ## unnest list of mentions_screen_name\n  unnest %\u003e% \n  ## count the number of coocurences\n  group_by(screen_name, mentions_screen_name) %\u003e% \n  tally(sort = T) %\u003e%\n  ungroup %\u003e% \n  ## drop missing values\n  drop_na %\u003e% \n  ## filter those coocurences that appear at least 2 times\n  filter(n \u003e 1) %\u003e% \n  ## transforming the dataframe to a graph object\n  as_tbl_graph() %\u003e% \n  ## calculating node centrality\n  mutate(centrality = centrality_degree(mode = 'in'))\n\nrt_graph %\u003e% \n  ## create graph layout\n  ggraph(layout = \"kk\") + \n  ## define edge aestetics\n  geom_edge_fan(aes(alpha = n, edge_width = n, color = n)) + \n  ## scale down link saturation\n  scale_edge_alpha(range = c(.5, .9)) +\n  ## define note size param\n  scale_edge_color_gradient(low = \"gray50\", high = \"#1874CD\") +\n  geom_node_point(aes(size = centrality), color = \"gray30\") +\n  ## equal width and height\n  coord_fixed() +\n  ## plain theme\n  theme_void() +\n  ## title\n  ggtitle(\"#ic2s2 Twitter Mentions Network\")\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-7-1.png)\u003c!-- --\u003e\n\n``` r\nrt_graph %\u003e% \n  ## create graph layout\n  ggraph(layout = \"kk\") + \n  ## define edge aestetics\n  geom_edge_fan(aes(alpha = n, edge_width = n, color = n)) + \n  ## scale down link saturation\n  scale_edge_alpha(range = c(.5, .9)) +\n  ## define note size param\n  scale_edge_color_gradient(low = \"gray50\", high = \"#1874CD\") +\n  geom_node_point(aes(size = centrality), color = \"gray30\") +\n  ## define node labels\n  geom_node_text(aes(label = name), repel = T, fontface = \"bold\") +\n  ## equal width and height\n  coord_fixed() +\n  ## plain theme\n  theme_void() +\n  ## title\n  ggtitle(\"#ic2s2 Twitter Mentions Network\")\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-7-2.png)\u003c!-- --\u003e\n\n``` r\nrt_graph %\u003e% \n  ## create graph layout\n  ggraph(layout = \"circle\") + \n  ## define edge aestetics\n  geom_edge_fan(aes(alpha = n, edge_width = n, color = n)) + \n  ## scale down link saturation\n  scale_edge_alpha(range = c(.5, .9)) +\n  ## define note size param\n  scale_edge_color_gradient(low = \"gray50\", high = \"#1874CD\") +\n  geom_node_point(aes(size = centrality), color = \"gray30\") +\n  ## define node labels\n  geom_node_text(aes(label = name), repel = F, fontface = \"bold\") +\n  ## equal width and height\n  coord_fixed() +\n  ## plain theme\n  theme_void() +\n  ## title\n  ggtitle(\"#ic2s2 Twitter Mentions Network\")\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-7-3.png)\u003c!-- --\u003e\n\n### Smaller Mentions Network (n \\\u003e 2)\n\n``` r\nrt_graph2 \u003c- rt %\u003e% \n  ## select relevant variables\n  dplyr::select(screen_name, mentions_screen_name) %\u003e% \n  ## unnest list of mentions_screen_name\n  unnest %\u003e% \n  ## count the number of coocurences\n  group_by(screen_name, mentions_screen_name) %\u003e% \n  tally(sort = T) %\u003e%\n  ungroup %\u003e% \n  ## drop missing values\n  drop_na %\u003e% \n  ## filter those coocurences that appear more than 2 times\n  filter(n \u003e 2) %\u003e% \n  ## transforming the dataframe to a graph object\n  as_tbl_graph() %\u003e% \n  ## calculating node centrality\n  mutate(centrality = centrality_degree(mode = 'in'))\n\nrt_graph2 %\u003e% \n  ## create graph layout\n  ggraph(layout = \"kk\") + \n  ## define edge aestetics\n  geom_edge_fan(aes(alpha = n, edge_width = n, color = n)) + \n  ## scale down link saturation\n  scale_edge_alpha(range = c(.5, .9)) +\n  ## define note size param\n  scale_edge_color_gradient(low = \"gray50\", high = \"#1874CD\") +\n  geom_node_point(aes(size = centrality), color = \"gray30\") +\n  ## equal width and height\n  coord_fixed() +\n  geom_node_text(aes(label = name), repel = T, fontface = \"bold\") +\n  ## plain theme\n  theme_void() +\n  ## title\n  ggtitle(\"#ic2s2 Twitter Mentions Network\")\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-8-1.png)\u003c!-- --\u003e\n\n## Most Frequent Hashtags\n\n``` r\nrt_hashtags \u003c- rt %\u003e% \n  filter(!is_retweet) %\u003e% \n  select(hashtags) %\u003e% \n  ## unnest list of hastags\n  unnest %\u003e% \n    na.omit %\u003e% \n  ## clean hashtags\n  mutate(hashtags = stringr::str_to_lower(hashtags) %\u003e% \n           str_replace_all(\"2018\", \"18\") %\u003e% \n           ## add #symbol to vector\n           paste0(\"#\", .)) %\u003e% \n  ## count each hashtag and sort\n  count(hashtags, sort = T) %\u003e% \n  filter(n \u003e 5)\n\nrt_hashtags %\u003e% \n  filter(hashtags != \"#ic2s2\") %\u003e%\n  mutate(hashtags = forcats::fct_reorder(hashtags, n)) %\u003e% \n  ggplot(aes(hashtags, n)) +\n  geom_bar(stat = \"identity\", alpha = .7) +\n  coord_flip() +\n  theme_minimal() +\n  ggtitle(\"Most Frequent Hastags related to #ic2s2\")\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-9-1.png)\u003c!-- --\u003e\n\n## Most Frequent Bigram Network\n\n``` r\ngg_bigram \u003c- rt %\u003e%\n  ## remove retweets\n  filter(!is_retweet) %\u003e% \n  select(text) %\u003e% \n  ## remove text noise\n  mutate(text = stringr::str_remove_all(text, \"w |amp \")) %\u003e% \n  ## remove retweets\n  filter(!stringr::str_detect(text, \"^RT\")) %\u003e% \n  ## remove urls\n  mutate(text = stringr::str_remove_all(text, \"https?[:]//[[:graph:]]+\")) %\u003e% \n  mutate(id = 1:n()) %\u003e% \n  ## split text into words\n  tidytext::unnest_tokens(word, text, token = \"words\") %\u003e% \n  ## remove stop words\n  anti_join(tidytext::stop_words) %\u003e% \n  ## paste words to text by id\n  group_by(id) %\u003e% \n  summarise(text = paste(word, collapse = \" \")) %\u003e% \n  ungroup %\u003e% \n  ## again split text into bigrams (word occurences or collocations)\n  tidytext::unnest_tokens(bigram, text, token = \"ngrams\", n = 2) %\u003e% \n  separate(bigram, c(\"word1\", \"word2\"), sep = \" \") %\u003e% \n  ## remove the hashtag and count bigrams \n  filter(word1 != \"ic2s2\", word2 != \"ic2s2\") %\u003e%\n  count(word1, word2, sort = T) %\u003e% \n  ## select first 50\n  slice(1:50) %\u003e% \n  drop_na() %\u003e%\n  ## create tidy graph object\n  as_tbl_graph() %\u003e% \n  ## calculate node centrality\n  mutate(centrality = centrality_degree(mode = 'in'))\n```\n\n``` r\ngg_bigram %\u003e% \n  ggraph() +\n  geom_edge_link(aes(edge_alpha = n, edge_width = n)) +\n  geom_node_point(aes(size = centrality)) + \n  geom_node_text(aes(label = name),  repel = TRUE) +\n  theme_void() +\n  scale_edge_alpha(\"\", range = c(0.3, .6)) +\n  ggtitle(\"Top Bigram Network from Tweets using hashtag #ic2s2\")\n```\n\n![](twitter_analysis_files/figure-gfm/unnamed-chunk-11-1.png)\u003c!-- --\u003e\n\n``` r\nsessionInfo()\n```\n\n    ## R version 3.6.0 (2019-04-26)\n    ## Platform: x86_64-w64-mingw32/x64 (64-bit)\n    ## Running under: Windows 10 x64 (build 17134)\n    ## \n    ## Matrix products: default\n    ## \n    ## locale:\n    ## [1] LC_COLLATE=English_Germany.1252  LC_CTYPE=English_Germany.1252   \n    ## [3] LC_MONETARY=English_Germany.1252 LC_NUMERIC=C                    \n    ## [5] LC_TIME=English_Germany.1252    \n    ## \n    ## attached base packages:\n    ## [1] stats     graphics  grDevices utils     datasets  methods   base     \n    ## \n    ## other attached packages:\n    ##  [1] tidygraph_1.1.2  igraph_1.2.4.1   ggraph_1.0.2     rtweet_0.6.8    \n    ##  [5] forcats_0.4.0    stringr_1.4.0    dplyr_0.8.1      purrr_0.3.2     \n    ##  [9] readr_1.3.1      tidyr_0.8.3.9000 tibble_2.1.3     ggplot2_3.2.0   \n    ## [13] tidyverse_1.2.1 \n    ## \n    ## loaded via a namespace (and not attached):\n    ##  [1] ggrepel_0.8.0     Rcpp_1.0.1        lubridate_1.7.4  \n    ##  [4] lattice_0.20-38   assertthat_0.2.1  zeallot_0.1.0    \n    ##  [7] digest_0.6.20     utf8_1.1.4        ggforce_0.2.2    \n    ## [10] R6_2.4.0          cellranger_1.1.0  plyr_1.8.4       \n    ## [13] backports_1.1.4   evaluate_0.13     httr_1.4.0       \n    ## [16] highr_0.8         pillar_1.4.1      rlang_0.4.0      \n    ## [19] lazyeval_0.2.2    readxl_1.3.1      rstudioapi_0.10  \n    ## [22] Matrix_1.2-17     rmarkdown_1.12.6  labeling_0.3     \n    ## [25] tidytext_0.2.0    polyclip_1.10-0   munsell_0.5.0    \n    ## [28] broom_0.5.2       janeaustenr_0.1.5 compiler_3.6.0   \n    ## [31] modelr_0.1.4      xfun_0.7          pkgconfig_2.0.2  \n    ## [34] htmltools_0.3.6   tidyselect_0.2.5  gridExtra_2.3    \n    ## [37] fansi_0.4.0       viridisLite_0.3.0 crayon_1.3.4     \n    ## [40] withr_2.1.2       SnowballC_0.6.0   MASS_7.3-51.4    \n    ## [43] grid_3.6.0        nlme_3.1-139      jsonlite_1.6     \n    ## [46] gtable_0.3.0      pacman_0.5.1      magrittr_1.5     \n    ## [49] tokenizers_0.2.1  scales_1.0.0      cli_1.1.0        \n    ## [52] stringi_1.4.3     farver_1.1.0      viridis_0.5.1    \n    ## [55] ggthemes_4.2.0    xml2_1.2.0        ellipsis_0.2.0.1 \n    ## [58] generics_0.0.2    vctrs_0.2.0       tools_3.6.0      \n    ## [61] glue_1.3.1        tweenr_1.0.1      hms_0.4.2        \n    ## [64] yaml_2.2.0        colorspace_1.4-1  rvest_0.3.4      \n    ## [67] knitr_1.23        haven_2.1.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavstats%2Fic2s2_conf_network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffavstats%2Fic2s2_conf_network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavstats%2Fic2s2_conf_network/lists"}