<p>Here we have multiple observations per state (I think I would say the units or rows correspond to “state-dates” or something like that). It’s not as “long” as possible, though, because we also have multiple columns corresponding to the two variables of interest: <code>cases</code> and <code>deaths</code>.</p>
<p>For the purposes of producing a multi-state and multivariate set of plots, the most important thing I want to do is consolidate my dataset into a format where I have the following columns: <code>date</code> (collapsed into weeks), <code>state</code>, <code>variable</code> (which will either have a value of <code>new cases</code> or <code>new deaths</code>), and a column for <code>value</code> that will hold the corresponding state-week count for the variable in each row. If that doesn’t make sense, don’t worry, we’ll get there soon enough.</p>
<p>Doing this involves a different approach to tidying up my data. I’ll start by dropping the step where I filtered by <code>state=="Illinois"</code> and replacing it with a <code>group_by</code> step before I create my <code>weekdate</code> variable. I’m also going to go ahead and drop the <code>date</code> and <code>fips</code> variables because they’re just getting in my way.</p>
<p>Here we have multiple observations per state (I think I would say the units or rows correspond to “state-dates” or something like that). It’s not as “long” as possible, though, because we also have multiple columns corresponding to the two variables of interest: <code>cases</code> and <code>deaths</code>.</p>
<p>For the purposes of producing a multi-state and multivariate set of plots, the most important thing I want to do is consolidate my dataset into a format where I have the following columns: <code>date</code> (collapsed into weeks), <code>state</code>, <code>variable</code> (which will either have a value of <code>new cases</code> or <code>new deaths</code>), and a column for <code>value</code> that will hold the corresponding state-week count for the variable in each row. If that doesn’t make sense, don’t worry, we’ll get there soon enough.</p>
<p>Doing this involves a different approach to tidying up my data. I’ll start by dropping the step where I filtered by <code>state=="Illinois"</code> and replacing it with a <code>group_by</code> step before I create my <code>weekdate</code> variable. I’m also going to go ahead and drop the <code>date</code> and <code>fips</code> variables because they’re just getting in my way.</p>