{"id":22966653,"url":"https://github.com/favstats/ecprconf2018_twitter","last_synced_at":"2026-01-15T22:34:22.080Z","repository":{"id":108349910,"uuid":"145918247","full_name":"favstats/ecprconf2018_twitter","owner":"favstats","description":"Analyzing Tweets during ECPR Conference 2018","archived":false,"fork":false,"pushed_at":"2018-08-25T13:12:34.000Z","size":1961,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T19:36:15.182Z","etag":null,"topics":["conference","ecpr","network-analysis","tweets","twitter"],"latest_commit_sha":null,"homepage":"http://www.favstats.eu/post/ecprconf18/","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":"2018-08-23T23:33:13.000Z","updated_at":"2018-09-30T15:15:04.000Z","dependencies_parsed_at":"2023-05-21T23:00:39.329Z","dependency_job_id":null,"html_url":"https://github.com/favstats/ecprconf2018_twitter","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%2Fecprconf2018_twitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fecprconf2018_twitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fecprconf2018_twitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/favstats%2Fecprconf2018_twitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/favstats","download_url":"https://codeload.github.com/favstats/ecprconf2018_twitter/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":["conference","ecpr","network-analysis","tweets","twitter"],"created_at":"2024-12-14T20:44:57.167Z","updated_at":"2026-01-15T22:34:22.075Z","avatar_url":"https://github.com/favstats.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"ECPR Conference 2018 Twitter Analysis\n================\nFabio\n2018-08-25\n\nThis is a short notebook outlining the code used to scrape tweets\nrelated to the ECPR Conference 2018 in Hamburg.\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, purrr, tidyr, rtweet, stringr, ggraph, igraph, tidygraph, forcats)\n```\n\n## Get Data\n\nCall Twitter API. If you want to scrape data yourself you have to\nregister a free account where you get your personal access point to\nTwitter. Check out [`rtweet`](https://github.com/mkearney/rtweet/) on\ngithub and follow their instructions to the twitter authentication.\n\n``` r\ntwitter_token \u003c- readRDS(\"twitter_token.rds\")\n\nrt \u003c- search_tweets(\n  \"#ecprconf18 OR #ecprconf2018\", n = 5000, include_rts = F, retryonratelimit = T\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: 1,399\n    ## Variables: 88\n    ## $ user_id                 \u003cchr\u003e \"21951668\", \"21951668\", \"21951668\", \"2...\n    ## $ status_id               \u003cchr\u003e \"1033324994552573952\", \"10325642035535...\n    ## $ created_at              \u003cdttm\u003e 2018-08-25 12:07:31, 2018-08-23 09:44...\n    ## $ screen_name             \u003cchr\u003e \"akreppel\", \"akreppel\", \"akreppel\", \"a...\n    ## $ text                    \u003cchr\u003e \"While the croissants can be treachero...\n    ## $ source                  \u003cchr\u003e \"Twitter for iPhone\", \"Twitter for iPa...\n    ## $ display_text_width      \u003cdbl\u003e 92, 110, 37, 126, 215, 165, 158, 32, 2...\n    ## $ reply_to_status_id      \u003cchr\u003e NA, \"1032375076652347393\", NA, NA, NA,...\n    ## $ reply_to_user_id        \u003cchr\u003e NA, \"21951668\", NA, NA, NA, NA, NA, NA...\n    ## $ reply_to_screen_name    \u003cchr\u003e NA, \"akreppel\", NA, NA, NA, NA, NA, NA...\n    ## $ is_quote                \u003clgl\u003e FALSE, FALSE, FALSE, FALSE, FALSE, FAL...\n    ## $ is_retweet              \u003clgl\u003e FALSE, FALSE, FALSE, FALSE, FALSE, FAL...\n    ## $ favorite_count          \u003cint\u003e 0, 2, 5, 2, 14, 9, 0, 2, 5, 5, 5, 2, 8...\n    ## $ retweet_count           \u003cint\u003e 0, 0, 0, 0, 5, 5, 0, 0, 4, 1, 1, 2, 2,...\n    ## $ hashtags                \u003clist\u003e [\"ecprconf18\", \"ECPRconf2018\", \"ecprc...\n    ## $ symbols                 \u003clist\u003e [NA, NA, NA, NA, NA, NA, NA, NA, NA, ...\n    ## $ urls_url                \u003clist\u003e [NA, NA, NA, NA, \"ecpr.eu/Events/Pane...\n    ## $ urls_t.co               \u003clist\u003e [NA, NA, NA, NA, \"https://t.co/KIzaT3...\n    ## $ urls_expanded_url       \u003clist\u003e [NA, NA, NA, NA, \"https://ecpr.eu/Eve...\n    ## $ media_url               \u003clist\u003e [NA, NA, NA, NA, \"http://pbs.twimg.co...\n    ## $ media_t.co              \u003clist\u003e [NA, NA, NA, NA, \"https://t.co/4Els2K...\n    ## $ media_expanded_url      \u003clist\u003e [NA, NA, NA, NA, \"https://twitter.com...\n    ## $ media_type              \u003clist\u003e [NA, NA, NA, NA, \"photo\", NA, \"photo\"...\n    ## $ ext_media_url           \u003clist\u003e [NA, NA, NA, NA, \"http://pbs.twimg.co...\n    ## $ ext_media_t.co          \u003clist\u003e [NA, NA, NA, NA, \"https://t.co/4Els2K...\n    ## $ ext_media_expanded_url  \u003clist\u003e [NA, NA, NA, NA, \"https://twitter.com...\n    ## $ ext_media_type          \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ mentions_user_id        \u003clist\u003e [NA, NA, NA, NA, NA, \"49383083\", NA, ...\n    ## $ mentions_screen_name    \u003clist\u003e [NA, NA, NA, NA, NA, \"ulrikeguerot\", ...\n    ## $ lang                    \u003cchr\u003e \"en\", \"en\", \"en\", \"en\", \"en\", \"en\", \"e...\n    ## $ quoted_status_id        \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"10329...\n    ## $ quoted_text             \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"\\\"Rev...\n    ## $ quoted_created_at       \u003cdttm\u003e NA, NA, NA, NA, NA, NA, NA, NA, 2018-...\n    ## $ quoted_source           \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"Twitt...\n    ## $ quoted_favorite_count   \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, 12, NA...\n    ## $ quoted_retweet_count    \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, 3, NA,...\n    ## $ quoted_user_id          \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"18984...\n    ## $ quoted_screen_name      \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"Lafle...\n    ## $ quoted_name             \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"Jean-...\n    ## $ quoted_followers_count  \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, 497, N...\n    ## $ quoted_friends_count    \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, 356, N...\n    ## $ quoted_statuses_count   \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, 335, N...\n    ## $ quoted_location         \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"Belgi...\n    ## $ quoted_description      \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"Assoc...\n    ## $ quoted_verified         \u003clgl\u003e NA, NA, NA, NA, NA, NA, NA, NA, FALSE,...\n    ## $ retweet_status_id       \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_text            \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_created_at      \u003cdttm\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, N...\n    ## $ retweet_source          \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_favorite_count  \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_retweet_count   \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_user_id         \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_screen_name     \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_name            \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_followers_count \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_friends_count   \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_statuses_count  \u003cint\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_location        \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_description     \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ retweet_verified        \u003clgl\u003e NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...\n    ## $ place_url               \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"https...\n    ## $ place_name              \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"Hambu...\n    ## $ place_full_name         \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"Hambu...\n    ## $ place_type              \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"city\"...\n    ## $ country                 \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"Germa...\n    ## $ country_code            \u003cchr\u003e NA, NA, NA, NA, NA, NA, NA, NA, \"DE\", ...\n    ## $ geo_coords              \u003clist\u003e [\u003cNA, NA\u003e, \u003cNA, NA\u003e, \u003cNA, NA\u003e, \u003cNA, N...\n    ## $ coords_coords           \u003clist\u003e [\u003cNA, NA\u003e, \u003cNA, NA\u003e, \u003cNA, NA\u003e, \u003cNA, N...\n    ## $ bbox_coords             \u003clist\u003e [\u003cNA, NA, NA, NA, NA, NA, NA, NA\u003e, \u003cN...\n    ## $ status_url              \u003cchr\u003e \"https://twitter.com/akreppel/status/1...\n    ## $ name                    \u003cchr\u003e \"(((Amie Kreppel)))\", \"(((Amie Kreppel...\n    ## $ location                \u003cchr\u003e \"Florida, USA\", \"Florida, USA\", \"Flori...\n    ## $ description             \u003cchr\u003e \"Jean Monnet Chair and Associate Profe...\n    ## $ url                     \u003cchr\u003e NA, NA, NA, NA, \"https://t.co/MslGy2Ml...\n    ## $ protected               \u003clgl\u003e FALSE, FALSE, FALSE, FALSE, FALSE, FAL...\n    ## $ followers_count         \u003cint\u003e 296, 296, 296, 296, 1245, 1245, 1245, ...\n    ## $ friends_count           \u003cint\u003e 355, 355, 355, 355, 475, 475, 475, 475...\n    ## $ listed_count            \u003cint\u003e 12, 12, 12, 12, 85, 85, 85, 85, 109, 1...\n    ## $ statuses_count          \u003cint\u003e 2789, 2789, 2789, 2789, 8805, 8805, 88...\n    ## $ favourites_count        \u003cint\u003e 3980, 3980, 3980, 3980, 0, 0, 0, 0, 24...\n    ## $ account_created_at      \u003cdttm\u003e 2009-02-26 01:23:21, 2009-02-26 01:23...\n    ## $ verified                \u003clgl\u003e FALSE, FALSE, FALSE, FALSE, FALSE, FAL...\n    ## $ profile_url             \u003cchr\u003e NA, NA, NA, NA, \"https://t.co/MslGy2Ml...\n    ## $ profile_expanded_url    \u003cchr\u003e NA, NA, NA, NA, \"http://www.jaruizso.e...\n    ## $ account_lang            \u003cchr\u003e \"en\", \"en\", \"en\", \"en\", \"en\", \"en\", \"e...\n    ## $ profile_banner_url      \u003cchr\u003e \"https://pbs.twimg.com/profile_banners...\n    ## $ profile_background_url  \u003cchr\u003e \"http://abs.twimg.com/images/themes/th...\n    ## $ profile_image_url       \u003cchr\u003e \"http://pbs.twimg.com/profile_images/2...\n\nThe top ten retweeted tweets.\n\n``` r\n# load(\"rt.Rdata\")\nrt %\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| jrteruel         | Cataluña y Escocia no son tan parecidas\\! Un análisis de discurso halla notables diferencias entre independentismos: recurrente retórica populista en Cat, pero no en Esc. Interesante esto d @josejolivas presentado en el panel de @\\_ignaciomolina \u003chttps://t.co/DuGF8ppfq6\u003e \\#ecprconf18 \u003chttps://t.co/OAh4CMMlqc\u003e |             64 |\n| policy\\_politics | A special issue challenging scholars of policy theory to change the way they produce and communicate research. Read it for free until 20 September: \u003chttps://t.co/iaMl4s08C6\u003e \\#ecprconf18 @ECPR @CairneyPaul @chris\\_weible \u003chttps://t.co/TsQBSlfN6T\u003e                                                                 |             27 |\n| DelDemUCan       | The countdown begins for the \\#ecprconf18 in Hamburg\\! Section conveners @NicoleCurato \u0026 @\\_SofieMarien put together a schedule of democratic innovations panels here. Check it out \u003chttps://t.co/e8PVzo8foA\u003e \u003chttps://t.co/kfEwLE6swv\u003e                                                                                |             23 |\n| BJPolS           | We are pleased to offer free access to a selection of the most-cited BJPolS articles until the end of 2018: \u003chttps://t.co/G2wKHDnTdL\u003e \\#ecprconf18 \u003chttps://t.co/rR7uPOwgCS\u003e                                                                                                                                           |             20 |\n| antje\\_wiener    | Delighted to see the book published: \\#Contestation and \\#Constitution of \\#Norms in \\#GlobalIR ⁦ ⁦@CUP\\_PoliSci⁩ ⁦@CUP\\_Law⁩ ⁦@InternatlTheory⁩ ⁦@JacquiTrue⁩ @SassanGholiagha⁩ ⁦@JuttaBrunnee⁩ @womenalsoknow⁩ \\#ecprconf18 \u003chttps://t.co/IbZUclVRpd\u003e                                                                |             19 |\n| CUP\\_PoliSci     | Do you want to know what to do with your first book proposal? Read a series of blog posts from a @CambridgeUP Publisher: \u003chttps://t.co/vGFEmb3r48\u003e \\#ecprconf18 \u003chttps://t.co/Z34hmGWfSe\u003e                                                                                                                              |             18 |\n| ECPR             | Are you joining us at the University of Hamburg for \\#ecprconf18? Rejoice\\! The printed programme is now available to view online \u003chttps://t.co/GN8e81PaXx\u003e \u003chttps://t.co/4lZBbhLxV0\u003e                                                                                                                                  |             16 |\n| LauraSeelkopf    | And here is the detailed programme of our section on the politics of taxation \\#ecprconf18 : come and listen to 7 panels with 32 papers written by 48 scholars from 40 different institutions and four continents \u003chttps://t.co/1ZcM1No3ck\u003e                                                                            |             14 |\n| sarahcpolitics   | Presenting at \\#ecprconf18 paper on political protest in the context of the global financial crisis. I find the crisis triggered mobilisations, but depressed participation trends more broadly. Saturday 2pm VMP 5, Rm 2067. @ValuesStudies. Download the paper: \u003chttps://t.co/TlPdTydQdf\u003e \u003chttps://t.co/PzzAPiPrYp\u003e  |             14 |\n| kimgron          | The \\#ecprconf18 starts on Thursday in Hamburg. We have a full \\#DemInno section 👍 Also, don’t miss the Standing Group on Democratic Innovations meeting on Friday at 1 pm, Building VMP 8, Room 105. Steering Committee candidates will present themselves there, election in September                               |             14 |\n\n## Timeline\n\nWhat was the best time to tweet?\n\n``` r\nrt %\u003e%\n  ## parse date format\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%\n  ## select relevant time period\n  filter(cdate \u003e= as.Date(\"2018-08-23\")) %\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  theme_minimal() +\n  ggtitle(\"Number of Tweets by Day and Hour\") +\n  xlab(\"Hour of the Day\") +\n  ylab(\"Number of Tweets\")\n```\n\n![](ecprconf2018_twitter_files/figure-gfm/unnamed-chunk-5-1.png)\u003c!-- --\u003e\n\n## Mentions Network\n\n``` r\nrt_graph \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 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(popularity = 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 = popularity), color = \"gray30\") +\n  ## equal width and height\n  coord_fixed() +\n  ## plain theme\n  theme_void() +\n  ## title\n  ggtitle(\"#ecprconf18 Twitter Mentions Network\")\n```\n\n![](ecprconf2018_twitter_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 = popularity), 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(\"#ecprconf18 Twitter Mentions Network\")\n```\n\n![](ecprconf2018_twitter_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 = popularity), 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(\"#ecprconf18 Twitter Mentions Network\")\n```\n\n![](ecprconf2018_twitter_files/figure-gfm/unnamed-chunk-6-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 at least 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(popularity = 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 = popularity), 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(\"#ecprconf18 Twitter Mentions Network\")\n```\n\n![](ecprconf2018_twitter_files/figure-gfm/unnamed-chunk-7-1.png)\u003c!-- --\u003e\n\n## Most Frequent Hashtags\n\n``` r\nrt_hashtags \u003c- rt %\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 != \"#ecprconf18\") %\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 #ecprconf18\")\n```\n\n![](ecprconf2018_twitter_files/figure-gfm/unnamed-chunk-8-1.png)\u003c!-- --\u003e\n\n## Most Frequent Bigram Network\n\n``` r\ngg_bigram \u003c- rt %\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 != \"ecprconf18\", word2 != \"ecprconf18\") %\u003e%\n  count(word1, word2, sort = T) %\u003e% \n  ## select first 100\n  slice(1:100) %\u003e% \n  drop_na() %\u003e%\n  ## create tidy graph object\n  as_tbl_graph() %\u003e% \n  ## calculate node centrality\n  mutate(Popularity = 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 = Popularity)) + \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 #ecprconf18\")\n```\n\n![](ecprconf2018_twitter_files/figure-gfm/unnamed-chunk-10-1.png)\u003c!-- --\u003e\n\n``` r\nsessionInfo()\n```\n\n    ## R version 3.5.0 (2018-04-23)\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=German_Germany.1252  LC_CTYPE=German_Germany.1252   \n    ## [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   \n    ## [5] LC_TIME=German_Germany.1252    \n    ## \n    ## attached base packages:\n    ## [1] stats     graphics  grDevices utils     datasets  methods   base     \n    ## \n    ## other attached packages:\n    ##  [1] bindrcpp_0.2.2     tidygraph_1.1.0    igraph_1.2.1      \n    ##  [4] ggraph_1.0.1.9999  rtweet_0.6.7.9000  forcats_0.3.0     \n    ##  [7] stringr_1.3.0      dplyr_0.7.5        purrr_0.2.4       \n    ## [10] readr_1.1.1        tidyr_0.8.1        tibble_1.4.2      \n    ## [13] ggplot2_3.0.0.9000 tidyverse_1.2.1   \n    ## \n    ## loaded via a namespace (and not attached):\n    ##  [1] ggrepel_0.8.0     Rcpp_0.12.18      lubridate_1.7.4  \n    ##  [4] lattice_0.20-35   assertthat_0.2.0  rprojroot_1.3-2  \n    ##  [7] digest_0.6.15     psych_1.8.3.3     ggforce_0.1.3    \n    ## [10] R6_2.2.2          cellranger_1.1.0  plyr_1.8.4       \n    ## [13] backports_1.1.2   evaluate_0.10.1   highr_0.6        \n    ## [16] httr_1.3.1        pillar_1.2.1      rlang_0.2.1      \n    ## [19] lazyeval_0.2.1    readxl_1.1.0      rstudioapi_0.7   \n    ## [22] Matrix_1.2-14     rmarkdown_1.9     labeling_0.3     \n    ## [25] tidytext_0.1.9    foreign_0.8-70    munsell_0.4.3    \n    ## [28] broom_0.4.4       janeaustenr_0.1.5 compiler_3.5.0   \n    ## [31] modelr_0.1.1      pkgconfig_2.0.1   mnormt_1.5-5     \n    ## [34] htmltools_0.3.6   tidyselect_0.2.4  gridExtra_2.3    \n    ## [37] viridisLite_0.3.0 crayon_1.3.4      withr_2.1.2      \n    ## [40] SnowballC_0.5.1   MASS_7.3-49       grid_3.5.0       \n    ## [43] nlme_3.1-137      jsonlite_1.5      gtable_0.2.0     \n    ## [46] pacman_0.4.6      magrittr_1.5      tokenizers_0.2.1 \n    ## [49] units_0.6-0       scales_0.5.0      cli_1.0.0        \n    ## [52] stringi_1.1.7     farver_1.0        reshape2_1.4.3   \n    ## [55] viridis_0.5.1     xml2_1.2.0        tools_3.5.0      \n    ## [58] glue_1.3.0        tweenr_0.1.5.9999 hms_0.4.2        \n    ## [61] parallel_3.5.0    yaml_2.1.19       colorspace_1.4-0 \n    ## [64] rvest_0.3.2       knitr_1.20        bindr_0.1.1      \n    ## [67] haven_1.1.2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavstats%2Fecprconf2018_twitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffavstats%2Fecprconf2018_twitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffavstats%2Fecprconf2018_twitter/lists"}