{"id":5904,"date":"2015-11-23T08:01:17","date_gmt":"2015-11-23T07:01:17","guid":{"rendered":"http:\/\/www.walkingrandomly.com\/?p=5904"},"modified":"2015-11-23T09:07:03","modified_gmt":"2015-11-23T08:07:03","slug":"twitter-wordcloud-using-r","status":"publish","type":"post","link":"https:\/\/walkingrandomly.com\/?p=5904","title":{"rendered":"Twitter wordcloud using R"},"content":{"rendered":"<p>A recent trend on Facebook is to create a <a href=\"http:\/\/www.thatsnonsense.com\/what-are-your-most-used-words-on-facebook-app-goes-viral\/\">wordcloud of all of your posts using an external service<\/a>. I chose not to use it because I tend to use Facebook for personal interactions among close friends and I didn&#8217;t want to send all of my data to another external company.<\/p>\n<p>Twitter is a different matter, however! All of the data is open and it&#8217;s very easy to write a computer program to generate Twitter world clouds without the need for an external service.<\/p>\n<p>I wrote a simple script in <a href=\"https:\/\/www.r-project.org\/\">R<\/a> that generates a wordcloud from the most recent 3200 tweets and outputs the top 200 words (<a href=\"https:\/\/github.com\/mikecroucher\/Social_Wordcloud\">get the code on github<\/a>). The script removes many of the uninteresting words such as the, of, and that would otherwise dominate the cloud. These <a href=\"https:\/\/en.wikipedia.org\/wiki\/Stop_words\">stopwords<\/a> come from the Top100Words list of the R package <a href=\"https:\/\/cran.r-project.org\/web\/packages\/qdap\/index.html\">qdap<\/a>\u00a0but I also added a few more such as &#8216;just&#8217; and &#8216;me&#8217; that I seem to use a lot.<\/p>\n<p>This is the current wordcloud for my twitter account, <a href=\"https:\/\/twitter.com\/walkingrandomly\">walkingrandomly<\/a>. Click on the image to see a bigger version. My main interests are very clear &#8211; Python programming, research software, data and anything that&#8217;s new!<\/p>\n<p><a href=\"https:\/\/www.walkingrandomly.com\/wp-content\/uploads\/2015\/11\/Mike.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5907\" title=\"walkingrandomly wordcloud. Click for larger version\" src=\"https:\/\/www.walkingrandomly.com\/wp-content\/uploads\/2015\/11\/Mike-300x275.jpg\" alt=\"Mike\" width=\"300\" height=\"275\" srcset=\"https:\/\/walkingrandomly.com\/wp-content\/uploads\/2015\/11\/Mike-300x275.jpg 300w, https:\/\/walkingrandomly.com\/wp-content\/uploads\/2015\/11\/Mike-1024x939.jpg 1024w, https:\/\/walkingrandomly.com\/wp-content\/uploads\/2015\/11\/Mike.jpg 1088w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Once I had seen my wordcloud, I wondered how things would look for other twitter users who I pay a lot of attention to. This is how it looks for Manchester University&#8217;s <a href=\"https:\/\/twitter.com\/nhigham\">Nick Higham<\/a>. Clearly he&#8217;s big on SIAM, Manchester, and Matrix Analysis!<\/p>\n<p><a href=\"https:\/\/www.walkingrandomly.com\/wp-content\/uploads\/2015\/11\/nhigham.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5910\" src=\"https:\/\/www.walkingrandomly.com\/wp-content\/uploads\/2015\/11\/nhigham-300x293.jpg\" alt=\"nhigham\" width=\"300\" height=\"293\" srcset=\"https:\/\/walkingrandomly.com\/wp-content\/uploads\/2015\/11\/nhigham-300x293.jpg 300w, https:\/\/walkingrandomly.com\/wp-content\/uploads\/2015\/11\/nhigham-1024x999.jpg 1024w, https:\/\/walkingrandomly.com\/wp-content\/uploads\/2015\/11\/nhigham.jpg 1086w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>I then looked at my manager at Sheffield University, <a href=\"https:\/\/twitter.com\/lawrennd\">Neil Lawrence<\/a>. Neil finds data and the city of Sheffield very important and also writes about workshops, science, blog posts and machine learning a lot.<\/p>\n<p><a href=\"https:\/\/www.walkingrandomly.com\/wp-content\/uploads\/2015\/11\/lawrennd.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5911\" src=\"https:\/\/www.walkingrandomly.com\/wp-content\/uploads\/2015\/11\/lawrennd-300x288.jpg\" alt=\"lawrennd\" width=\"300\" height=\"288\" srcset=\"https:\/\/walkingrandomly.com\/wp-content\/uploads\/2015\/11\/lawrennd-300x288.jpg 300w, https:\/\/walkingrandomly.com\/wp-content\/uploads\/2015\/11\/lawrennd-1024x983.jpg 1024w, https:\/\/walkingrandomly.com\/wp-content\/uploads\/2015\/11\/lawrennd.jpg 1210w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The R code that generated these wordclouds is available on github but it won&#8217;t work out of the box. You&#8217;ll need to <a href=\"https:\/\/apps.twitter.com\">register with twitter for app development<\/a> (It&#8217;s free and fairly straightforward) and get various access keys before you can use the code.<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/mikecroucher\/Social_Wordcloud\">Get the code at github<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A recent trend on Facebook is to create a wordcloud of all of your posts using an external service. I chose not to use it because I tend to use Facebook for personal interactions among close friends and I didn&#8217;t want to send all of my data to another external company. Twitter is a different [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[45,61,7,36,30],"tags":[],"class_list":["post-5904","post","type-post","status-publish","format-standard","hentry","category-just-for-fun","category-natural-language","category-programming","category-r","category-the-internet"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3swhs-1xe","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/5904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5904"}],"version-history":[{"count":6,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/5904\/revisions"}],"predecessor-version":[{"id":5914,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=\/wp\/v2\/posts\/5904\/revisions\/5914"}],"wp:attachment":[{"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/walkingrandomly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}