title: Compare two vectors of different length in R
body: <p>I've been struggling with this problem, and decided to ask for some help after some fails..</p>
  
  <p>Here is my problem, I want to divide these two vectors based on the day, for instance 2012-12-11 will be 3/17 and 2012-12-12 should be 0/7. However I can't seem to figure out how to do this..</p>
  
  <pre><code>&gt; ili
  
  2012-12-11 2012-12-13 2012-12-14 2012-12-17 
       3          6          7          1 
  &gt; no.ili
  
  2012-12-11 2012-12-12 2012-12-13 2012-12-14 2012-12-15 2012-12-16 2012-12-17 
      17          7        232        322         38         21         36 
  </code></pre>
  
  <p>The last attempt was to loop over the two vectors and add the value or zero to a new vector however when I use <code>%in%</code> it doesn't put the values in order (obviously) but if I use <code>==</code> it also doesn't work..</p>
  
  <pre><code> days.ili &lt;- unique(one.three$timestamp)
   days &lt;- unique(one.week$timestamp)
   ili.vec &lt;- rep(0, length(days))
  
   for (i in 1:length(days)) {
       if (days.ili[i] %in% days) {
           ili.vec[i] &lt;- ili[i]
       } else {
           ili.vec[i] &lt;- 0
       }
   }
  </code></pre>
  
  <p>I must be forgetting some thing since I'm not being able to see through this problem.. Can anyone give me any idea about the best way to achieve this in R?</p>
  
  <p>Perhaps an option will be using <code>merge</code> ..</p>