title: Transforming raw timeseries data into an organized dataframe in R
body: <p>I have a Covid-19 dataset containing information for each state of Brazil. The dates are the same for all states.</p>
  
  <pre><code>   region   state  date         newCases   cumulativeCases  newDeaths   cumulativeDeaths
  1  Norte     RO 30/01/2020          0               0           0                0
  2  Norte     RO 31/01/2020          0               0           0                0
  3  Norte     RO 01/02/2020          0               0           0                0
  4  Norte     RO 02/02/2020          0               0           0                0
  5  Norte     RO 03/02/2020          0               0           0                0
  6  Norte     RO 04/02/2020          0               0           0                0
  </code></pre>
  
  <p>I need to transform this data into a cases (or deaths) matrix with states in rows and dates in columns, like this:</p>
  
  <p><a href="https://i.stack.imgur.com/7Cbh8.png" rel="nofollow noreferrer">matrix</a></p>
  
  <p>I was able to do this using a for loop but I'm looking for a more simple and efficient way to do this task. Is it possible?</p>
  
  <p>Thanks in advance!</p>