<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Liam A.</title>
    <description>The latest articles on DEV Community by Liam A. (@liama482).</description>
    <link>https://dev.to/liama482</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F350709%2F9d9bf44a-783c-4888-845c-ba47d934a5a3.png</url>
      <title>DEV Community: Liam A.</title>
      <link>https://dev.to/liama482</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/liama482"/>
    <language>en</language>
    <item>
      <title>Attempt to make an animated map in R</title>
      <dc:creator>Liam A.</dc:creator>
      <pubDate>Sat, 14 Mar 2020 21:29:22 +0000</pubDate>
      <link>https://dev.to/liama482/attempt-to-make-an-animated-map-in-r-3am4</link>
      <guid>https://dev.to/liama482/attempt-to-make-an-animated-map-in-r-3am4</guid>
      <description>&lt;p&gt;I have a set of data sets (from the U.S. Census Bureau’s American Community Survey) that list how many people drive to work with a commute length that is one of the following time intervals: 14 minutes or less 15-29 minutes 30-44 minutes 45-59 minutes 60 minutes or more.&lt;/p&gt;

&lt;p&gt;The data is polygons and I am coding in R Studio. What I would like to do is show an animation of 5 plots, one plot for each of these five time intervals listed above. Specifically I am looking at data by census tract in five Maryland counties which are suburbs of Washington, D.C.: Calvert, Charles, Frederick, Montgomery, and Prince George's counties.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;After&lt;/em&gt; tidying the data, right now I have the code posted below as an attempt &lt;strong&gt;to make an animated series of plots, using ggplot and gganimate&lt;/strong&gt;. I have largely been inspired &lt;a href="https://mikeyharper.uk/animated-plots-with-r/"&gt;by this example&lt;/a&gt;, but I also looked &lt;a href="//mikeyharper.uk/animated-plots-with-r/%20&amp;amp;%20%20d4tagirl.com/2017/05/how-to-plot-animated-maps-with-gganimate%20article/post"&gt;at this article/post&lt;/a&gt; and I have incorporated these pieces of advice into the code below.&lt;br&gt;
To be clear, my plots I’ve made so far are intended to have plot_DrAl1 be the one showing the number of people driving to work alone whose commute is 14 minutes or less, while plot_DrAl2 is for people with commutes of 15-29 minutes, plot_DrAl3 is for people with commutes of 30-44 minutes and plot_DrAl4 is for people with commutes of 45-59 minutes. Eventually, I aim to add a fifth plot displaying the number of people driving to work alone with commutes of 60 minutes or more&lt;/p&gt;

&lt;p&gt;If someone has an idea of what I am doing wrong or how I can better achieve my goal, please let me know! And as a disclaimer, yes &lt;em&gt;I have already posted&lt;/em&gt; this question on Stackoverflow but &lt;a href="//dev.to/codemouse92/has-stackoverflow-become-an-antipattern-3icb"&gt;after reading this post&lt;/a&gt; I am wondering whether I will ever get an answer on SO&lt;/p&gt;

&lt;p&gt;My Code at this point:&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  set-up
&lt;/h1&gt;

&lt;p&gt;library(gganimate)&lt;br&gt;
library(tidyverse)&lt;br&gt;
library(sf)&lt;br&gt;
library(readx1)&lt;br&gt;
library(tidycensus)&lt;br&gt;
library(tmap)&lt;br&gt;
library(leaflet)&lt;br&gt;
library(gapminder)&lt;br&gt;
library(maps)&lt;br&gt;
library(httr)&lt;br&gt;
library(hrbrthemes)&lt;br&gt;
library(GISTools)&lt;br&gt;
library(sp)&lt;br&gt;
library(raster)&lt;br&gt;
setwd("Z:/ENVS_117/final_project/tidycensus_data")&lt;br&gt;
census_api_key("ca1e6bccd0bcdbf2cd3462c3f055921aae8e3957")&lt;/p&gt;
&lt;h1&gt;
  
  
  PLOTS
&lt;/h1&gt;

&lt;p&gt;theme_set(theme_bw())&lt;/p&gt;

&lt;p&gt;plot_DrAl1 &amp;lt;- ggplot() +&lt;br&gt;
    geom_polygon(data=dc_area, aes(Longitude, Lat), fill = "#e6d4ff") +&lt;br&gt;
    geom_polygon(data=cars_0014, aes(x = &lt;code&gt;Longitude&lt;/code&gt;, y = &lt;code&gt;Lat&lt;/code&gt;, fill = &lt;code&gt;Perc_DrAl14&lt;/code&gt;)) +&lt;/p&gt;

&lt;p&gt;# gganimate parts&lt;br&gt;
    transition_states(&lt;code&gt;Perc_DrAl14&lt;/code&gt;, transition_length = 2, state_length = 20) +&lt;br&gt;
    enter_fade() +&lt;br&gt;
    exit_fade() +&lt;/p&gt;

&lt;p&gt;# Styling&lt;br&gt;
    coord_equal(xlim = c(-75000, 825000), ylim = c(0, 1200000)) +&lt;br&gt;
    theme(panel.grid.major = 4,&lt;br&gt;
          panel.grid.minor = 0,&lt;br&gt;
          axis.text = element_blank(),&lt;br&gt;
          axis.title = element_blank(),&lt;br&gt;
          axis.ticks = element_blank(),&lt;br&gt;
          panel.background = element_rect(fill = "grey99", colour = "grey80"),&lt;br&gt;
          plot.title = element_text(hjust = 0, size = 16, vjust=0))&lt;/p&gt;

&lt;p&gt;print(plot_DrAl1 + plot_DrAl2 + plot_DrAl3 - plot_DrAl4 + plot_layout(ncol = 1, heights = c(5, 1)))&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;}, movie.name = "windDevelopment.gif", interval = 1, ani.width = 1000, ani.height = 700))  &lt;/p&gt;

&lt;p&gt;animate(plot_DrAl, length = 15, width = 700, height = 400)&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>r</category>
      <category>help</category>
      <category>animation</category>
    </item>
  </channel>
</rss>
