

{"id":4345,"date":"2016-04-17T10:43:11","date_gmt":"2016-04-17T15:43:11","guid":{"rendered":"http:\/\/rud.is\/b\/?p=4345"},"modified":"2018-07-19T10:27:04","modified_gmt":"2018-07-19T15:27:04","slug":"ggplot2-exercising-with-ggalt-dumbbells","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/","title":{"rendered":"(ggplot2) Exercising with (ggalt) dumbbells"},"content":{"rendered":"<p>I follow the most excellent Pew Research folks on Twitter to stay in tune with what&#8217;s happening (statistically speaking) with the world. Today, they tweeted this excerpt from their 2015 Global Attitudes survey:<\/p>\n<blockquote class=\"twitter-tweet\" data-lang=\"en\">\n<p lang=\"en\" dir=\"ltr\">The age gap in social media use around the world <a href=\"https:\/\/t.co\/0Dq1PcbExG\">https:\/\/t.co\/0Dq1PcbExG<\/a> <a href=\"https:\/\/t.co\/9HBM7gLxwR\">pic.twitter.com\/9HBM7gLxwR<\/a><\/p>\n<p>&mdash; PewResearch Internet (@pewinternet) <a href=\"https:\/\/mobile.twitter.com\/pewinternet\/status\/721688920476364800\">April 17, 2016<\/a><\/p><\/blockquote>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>I thought it might be helpful to folks if I made a highly aesthetically tuned version  of Pew&#8217;s chart (though I chose to go a bit more minimal in terms of styling than they did) with the new <code>geom_dumbbell()<\/code> in the development version of <code>ggalt<\/code>. The source (below) is annotated, but please drop a note in the comments if any of the code would benefit from more exposition.<\/p>\n<p>I&#8217;ve also switched to using the <a href=\"http:\/\/prismjs.com\">Prism<\/a> javascript library starting with this post after seeing how well it works in RStudio&#8217;s <code>flexdashboard<\/code> package. If the &#8220;light on black&#8221; is hard to read or distracting, drop a note here and I&#8217;ll switch the theme if enough folks are having issues.<\/p>\n<pre id=\"prism-r-code\"><code class=\"language-r\">library(ggplot2) # devtools::install_github(&quot;hadley\/ggplot2&quot;)\r\nlibrary(ggalt)   # devtools::install_github(&quot;hrbrmstr\/ggalt&quot;)\r\nlibrary(dplyr)   # for data_frame() &amp; arrange()\r\n\r\n# I&#039;m not crazy enough to input all the data; this will have to do for the example\r\ndf &lt;- data_frame(country=c(&quot;Germany&quot;, &quot;France&quot;, &quot;Vietnam&quot;, &quot;Japan&quot;, &quot;Poland&quot;, &quot;Lebanon&quot;,\r\n                           &quot;Australia&quot;, &quot;South\\nKorea&quot;, &quot;Canada&quot;, &quot;Spain&quot;, &quot;Italy&quot;, &quot;Peru&quot;,\r\n                           &quot;U.S.&quot;, &quot;UK&quot;, &quot;Mexico&quot;, &quot;Chile&quot;, &quot;China&quot;, &quot;India&quot;),\r\n                 ages_35=c(0.39, 0.42, 0.49, 0.43, 0.51, 0.57,\r\n                           0.60, 0.45, 0.65, 0.57, 0.57, 0.65,\r\n                           0.63, 0.59, 0.67, 0.75, 0.52, 0.48),\r\n                 ages_18_to_34=c(0.81, 0.83, 0.86, 0.78, 0.86, 0.90,\r\n                                 0.91, 0.75, 0.93, 0.85, 0.83, 0.91,\r\n                                 0.89, 0.84, 0.90, 0.96, 0.73, 0.69),\r\n                 diff=sprintf(&quot;+%d&quot;, as.integer((ages_18_to_34-ages_35)*100)))\r\n\r\n# we want to keep the order in the plot, so we use a factor for country\r\ndf &lt;- arrange(df, desc(diff))\r\ndf$country &lt;- factor(df$country, levels=rev(df$country))\r\n\r\n# we only want the first line values with &quot;%&quot; symbols (to avoid chart junk)\r\n# quick hack; there is a more efficient way to do this\r\npercent_first &lt;- function(x) {\r\n  x &lt;- sprintf(&quot;%d%%&quot;, round(x*100))\r\n  x[2:length(x)] &lt;- sub(&quot;%$&quot;, &quot;&quot;, x[2:length(x)])\r\n  x\r\n}\r\n\r\ngg &lt;- ggplot()\r\n# doing this vs y axis major grid line\r\ngg &lt;- gg + geom_segment(data=df, aes(y=country, yend=country, x=0, xend=1), color=&quot;#b2b2b2&quot;, size=0.15)\r\n# dum\u2026dum\u2026dum!bell\r\ngg &lt;- gg + geom_dumbbell(data=df, aes(y=country, x=ages_35, xend=ages_18_to_34),\r\n                         size=1.5, color=&quot;#b2b2b2&quot;, point.size.l=3, point.size.r=3,\r\n                         point.colour.l=&quot;#9fb059&quot;, point.colour.r=&quot;#edae52&quot;)\r\n# text below points\r\ngg &lt;- gg + geom_text(data=filter(df, country==&quot;Germany&quot;),\r\n                     aes(x=ages_35, y=country, label=&quot;Ages 35+&quot;),\r\n                     color=&quot;#9fb059&quot;, size=3, vjust=-2, fontface=&quot;bold&quot;, family=&quot;Calibri&quot;)\r\ngg &lt;- gg + geom_text(data=filter(df, country==&quot;Germany&quot;),\r\n                     aes(x=ages_18_to_34, y=country, label=&quot;Ages 18-34&quot;),\r\n                     color=&quot;#edae52&quot;, size=3, vjust=-2, fontface=&quot;bold&quot;, family=&quot;Calibri&quot;)\r\n# text above points\r\ngg &lt;- gg + geom_text(data=df, aes(x=ages_35, y=country, label=percent_first(ages_35)),\r\n                     color=&quot;#9fb059&quot;, size=2.75, vjust=2.5, family=&quot;Calibri&quot;)\r\ngg &lt;- gg + geom_text(data=df, color=&quot;#edae52&quot;, size=2.75, vjust=2.5, family=&quot;Calibri&quot;,\r\n                     aes(x=ages_18_to_34, y=country, label=percent_first(ages_18_to_34)))\r\n# difference column\r\ngg &lt;- gg + geom_rect(data=df, aes(xmin=1.05, xmax=1.175, ymin=-Inf, ymax=Inf), fill=&quot;#efefe3&quot;)\r\ngg &lt;- gg + geom_text(data=df, aes(label=diff, y=country, x=1.1125), fontface=&quot;bold&quot;, size=3, family=&quot;Calibri&quot;)\r\ngg &lt;- gg + geom_text(data=filter(df, country==&quot;Germany&quot;), aes(x=1.1125, y=country, label=&quot;DIFF&quot;),\r\n                     color=&quot;#7a7d7e&quot;, size=3.1, vjust=-2, fontface=&quot;bold&quot;, family=&quot;Calibri&quot;)\r\ngg &lt;- gg + scale_x_continuous(expand=c(0,0), limits=c(0, 1.175))\r\ngg &lt;- gg + scale_y_discrete(expand=c(0.075,0))\r\ngg &lt;- gg + labs(x=NULL, y=NULL, title=&quot;The social media age gap&quot;,\r\n                subtitle=&quot;Adult internet users or reported smartphone owners who\\nuse social networking sites&quot;,\r\n                caption=&quot;Source: Pew Research Center, Spring 2015 Global Attitudes Survey. Q74&quot;)\r\ngg &lt;- gg + theme_bw(base_family=&quot;Calibri&quot;)\r\ngg &lt;- gg + theme(panel.grid.major=element_blank())\r\ngg &lt;- gg + theme(panel.grid.minor=element_blank())\r\ngg &lt;- gg + theme(panel.border=element_blank())\r\ngg &lt;- gg + theme(axis.ticks=element_blank())\r\ngg &lt;- gg + theme(axis.text.x=element_blank())\r\ngg &lt;- gg + theme(plot.title=element_text(face=&quot;bold&quot;))\r\ngg &lt;- gg + theme(plot.subtitle=element_text(face=&quot;italic&quot;, size=9, margin=margin(b=12)))\r\ngg &lt;- gg + theme(plot.caption=element_text(size=7, margin=margin(t=12), color=&quot;#7a7d7e&quot;))\r\ngg<\/code><\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"510\" height=\"754\" data-attachment-id=\"4353\" data-permalink=\"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/rstudio-10\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=870%2C1287&amp;ssl=1\" data-orig-size=\"870,1287\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"RStudio\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=510%2C754&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?resize=510%2C754&#038;ssl=1\" alt=\"RStudio\" class=\"aligncenter size-full wp-image-4353\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I follow the most excellent Pew Research folks on Twitter to stay in tune with what&#8217;s happening (statistically speaking) with the world. Today, they tweeted this excerpt from their 2015 Global Attitudes survey: The age gap in social media use around the world https:\/\/t.co\/0Dq1PcbExG pic.twitter.com\/9HBM7gLxwR &mdash; PewResearch Internet (@pewinternet) April 17, 2016 I thought it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4353,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[24,678,673,674,753,91],"tags":[810],"class_list":["post-4345","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-charts-graphs","category-data-visualization","category-datavis-2","category-dataviz","category-ggplot","category-r","tag-post"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>(ggplot2) Exercising with (ggalt) dumbbells - rud.is<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"(ggplot2) Exercising with (ggalt) dumbbells - rud.is\" \/>\n<meta property=\"og:description\" content=\"I follow the most excellent Pew Research folks on Twitter to stay in tune with what&#8217;s happening (statistically speaking) with the world. Today, they tweeted this excerpt from their 2015 Global Attitudes survey: The age gap in social media use around the world https:\/\/t.co\/0Dq1PcbExG pic.twitter.com\/9HBM7gLxwR &mdash; PewResearch Internet (@pewinternet) April 17, 2016 I thought it [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2016-04-17T15:43:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-07-19T15:27:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=870%2C1287&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"870\" \/>\n\t<meta property=\"og:image:height\" content=\"1287\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"hrbrmstr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hrbrmstr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"(ggplot2) Exercising with (ggalt) dumbbells\",\"datePublished\":\"2016-04-17T15:43:11+00:00\",\"dateModified\":\"2018-07-19T15:27:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/\"},\"wordCount\":186,\"commentCount\":24,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/RStudio.png?fit=870%2C1287&ssl=1\",\"keywords\":[\"post\"],\"articleSection\":[\"Charts &amp; Graphs\",\"Data Visualization\",\"DataVis\",\"DataViz\",\"ggplot\",\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/\",\"name\":\"(ggplot2) Exercising with (ggalt) dumbbells - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/RStudio.png?fit=870%2C1287&ssl=1\",\"datePublished\":\"2016-04-17T15:43:11+00:00\",\"dateModified\":\"2018-07-19T15:27:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/RStudio.png?fit=870%2C1287&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/04\\\/RStudio.png?fit=870%2C1287&ssl=1\",\"width\":870,\"height\":1287},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/04\\\/17\\\/ggplot2-exercising-with-ggalt-dumbbells\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"(ggplot2) Exercising with (ggalt) dumbbells\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/\",\"name\":\"rud.is\",\"description\":\"&quot;In God we trust. All others must bring data&quot;\",\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rud.is\\\/b\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\",\"name\":\"hrbrmstr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"width\":460,\"height\":460,\"caption\":\"hrbrmstr\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\"},\"description\":\"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7\",\"sameAs\":[\"http:\\\/\\\/rud.is\"],\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/author\\\/hrbrmstr\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"(ggplot2) Exercising with (ggalt) dumbbells - rud.is","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/","og_locale":"en_US","og_type":"article","og_title":"(ggplot2) Exercising with (ggalt) dumbbells - rud.is","og_description":"I follow the most excellent Pew Research folks on Twitter to stay in tune with what&#8217;s happening (statistically speaking) with the world. Today, they tweeted this excerpt from their 2015 Global Attitudes survey: The age gap in social media use around the world https:\/\/t.co\/0Dq1PcbExG pic.twitter.com\/9HBM7gLxwR &mdash; PewResearch Internet (@pewinternet) April 17, 2016 I thought it [&hellip;]","og_url":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/","og_site_name":"rud.is","article_published_time":"2016-04-17T15:43:11+00:00","article_modified_time":"2018-07-19T15:27:04+00:00","og_image":[{"width":870,"height":1287,"url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=870%2C1287&ssl=1","type":"image\/png"}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"(ggplot2) Exercising with (ggalt) dumbbells","datePublished":"2016-04-17T15:43:11+00:00","dateModified":"2018-07-19T15:27:04+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/"},"wordCount":186,"commentCount":24,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=870%2C1287&ssl=1","keywords":["post"],"articleSection":["Charts &amp; Graphs","Data Visualization","DataVis","DataViz","ggplot","R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/","url":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/","name":"(ggplot2) Exercising with (ggalt) dumbbells - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=870%2C1287&ssl=1","datePublished":"2016-04-17T15:43:11+00:00","dateModified":"2018-07-19T15:27:04+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=870%2C1287&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=870%2C1287&ssl=1","width":870,"height":1287},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2016\/04\/17\/ggplot2-exercising-with-ggalt-dumbbells\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"(ggplot2) Exercising with (ggalt) dumbbells"}]},{"@type":"WebSite","@id":"https:\/\/rud.is\/b\/#website","url":"https:\/\/rud.is\/b\/","name":"rud.is","description":"&quot;In God we trust. All others must bring data&quot;","publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rud.is\/b\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886","name":"hrbrmstr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","width":460,"height":460,"caption":"hrbrmstr"},"logo":{"@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1"},"description":"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7","sameAs":["http:\/\/rud.is"],"url":"https:\/\/rud.is\/b\/author\/hrbrmstr\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/RStudio.png?fit=870%2C1287&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p23idr-185","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":5050,"url":"https:\/\/rud.is\/b\/2017\/02\/15\/ggalt-0-4-0-now-on-cran\/","url_meta":{"origin":4345,"position":0},"title":"ggalt 0.4.0 now on CRAN","author":"hrbrmstr","date":"2017-02-15","format":false,"excerpt":"I'm uncontainably excited to report that the ggplot2 extension package ggalt is now on CRAN. The absolute best part of this package is the R community members who contributed suggestions and new geoms, stats, annotations and integration features. This release would not be possible without the PRs from: Ben Bolker\u2026","rel":"","context":"In &quot;ggplot&quot;","block_context":{"text":"ggplot","link":"https:\/\/rud.is\/b\/category\/ggplot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/02\/RStudio-1.png?fit=1200%2C510&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/02\/RStudio-1.png?fit=1200%2C510&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/02\/RStudio-1.png?fit=1200%2C510&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/02\/RStudio-1.png?fit=1200%2C510&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/02\/RStudio-1.png?fit=1200%2C510&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3832,"url":"https:\/\/rud.is\/b\/2015\/12\/28\/world-map-panel-plots-with-ggplot2-2-0-ggalt\/","url_meta":{"origin":4345,"position":1},"title":"World Map Panel Plots with ggplot2 2.0 &#038; ggalt","author":"hrbrmstr","date":"2015-12-28","format":false,"excerpt":"James Austin (@awhstin) made some #spiffy 4-panel maps with base R graphics but also posited he didn't use ggplot2 because: \u2026ggplot2 and maps currently do not support world maps at this point, which does not give us a great overall view. That is certainly a box I would not put\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":4285,"url":"https:\/\/rud.is\/b\/2016\/04\/12\/beating-lollipops-into-dumbbells\/","url_meta":{"origin":4345,"position":2},"title":"Beating lollipops into dumbbells","author":"hrbrmstr","date":"2016-04-12","format":false,"excerpt":"Shortly after I added lollipop charts to ggalt I had a few requests for a dumbbell geom. It wasn't difficult to do modify the underlying lollipop Geoms to make a geom_dumbbell(). Here it is in action: library(ggplot2) library(ggalt) # devtools::install_github(\"hrbrmstr\/ggalt\") library(dplyr) # from: https:\/\/plot.ly\/r\/dumbbell-plots\/ URL","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/Fullscreen_4_12_16__8_38_PM.png?fit=1200%2C1046&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":4254,"url":"https:\/\/rud.is\/b\/2016\/04\/07\/geom_lollipop-by-the-chartettes\/","url_meta":{"origin":4345,"position":3},"title":"geom_lollipop() by the Chartettes","author":"hrbrmstr","date":"2016-04-07","format":false,"excerpt":">UPDATE: Changed code to reflect the new `horizontal` parameter for `geom_lollipop()` I make a fair share of bar charts throughout the day and really like switching to lollipop charts to mix things up a bit and enhance the visual appeal. They're easy to do in `ggplot2`, just use your traditional\u2026","rel":"","context":"In &quot;Data Visualization&quot;","block_context":{"text":"Data Visualization","link":"https:\/\/rud.is\/b\/category\/data-visualization\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/download.png?fit=1200%2C1114&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/download.png?fit=1200%2C1114&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/download.png?fit=1200%2C1114&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/download.png?fit=1200%2C1114&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/04\/download.png?fit=1200%2C1114&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":4852,"url":"https:\/\/rud.is\/b\/2017\/01\/08\/2017-01-authored-package-updates\/","url_meta":{"origin":4345,"position":4},"title":"2017-01 Authored Package Updates","author":"hrbrmstr","date":"2017-01-08","format":false,"excerpt":"The rest of the month is going to be super-hectic and it's unlikely I'll be able to do any more to help the push to CRAN 10K, so here's a breakdown of CRAN and GitHub new packages & package updates that I felt were worth raising awareness on: epidata I\u2026","rel":"","context":"In &quot;dplyr&quot;","block_context":{"text":"dplyr","link":"https:\/\/rud.is\/b\/category\/dplyr\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/epi2.png?fit=982%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/epi2.png?fit=982%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/epi2.png?fit=982%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/01\/epi2.png?fit=982%2C1200&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":6917,"url":"https:\/\/rud.is\/b\/2017\/10\/30\/gg_tweeting-power-outages\/","url_meta":{"origin":4345,"position":5},"title":"gg_tweet&#8217;ing Power Outages","author":"hrbrmstr","date":"2017-10-30","format":false,"excerpt":"As many folks know, I live in semi-rural Maine and we were hit pretty hard with a wind+rain storm Sunday to Monday. The hrbrmstr compound had no power (besides a generator) and no stable\/high-bandwidth internet (Verizon LTE was heavily congested) since 0500 Monday and still does not as I write\u2026","rel":"","context":"In &quot;ggplot&quot;","block_context":{"text":"ggplot","link":"https:\/\/rud.is\/b\/category\/ggplot\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/4345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/comments?post=4345"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/4345\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media\/4353"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=4345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=4345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=4345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}