title: Fill a data frame with NA in R
body: <p>Suppose I have a dataset like myData below:</p>
  
  <pre><code>set.seed(1234)
  
  Date &lt;- seq(as.Date("1990-01-01"), as.Date("1990-12-01"), "months")
  Date &lt;- rep(Date, 5)
  
  Species &lt;- rep(c("cat", "lion", "tiger", "leopard", "cheetah"), each=12)
  
  Measurement &lt;- rnorm(60)
  
  index &lt;- sample(1:60, 10)
  
  myData &lt;- data.frame(Date[-index], Species[-index], Measurement[-index])
  </code></pre>
  
  <p>Notice myData doesn't have all the possible combinations between Date and Species. There are 10 missing rows. I want to create a new data frame (let's say myData2) where I have all the possible combinations between Date and Species, i.e., myData 2 will have 60 rows. The value of Measurement in myData2 should be its original value, if the particular combination of Date and Species is present in myData, or NA, if this combination is missing.</p>
  
  <p>I'm trying to accomplish this with two nested for loops, but it is not working. I know I'm making mistakes, but I can't figure out what they are.</p>