title: Julia: Find the intersection of two vectors and their indices to help concatenate two time series
body: <p>I'm trying to learn the Julia language, so I'm attempting to port some MATLAB and Octave code I have lying around to help me learn.</p>
  
  <p>Specifically in this instance, the reason I'm looking for a way to determine the indices is because I'm attempting to horizontally concatenate two time series by their dates so I can test for conintegration, and I've used the intersect function as one of the intermediate steps within MATLAB/Ocatve to allow me to accomplish this in the past.</p>
  
  <pre><code>Time series 1 example
  +------------+--------+
  | Date       |  Value |
  +------------+--------+
  | 2014-03-01 |     11 |
  | 2014-03-02 |     12 |
  | 2014-03-03 |     13 |
  | 2014-03-04 |     14 |
  | 2014-03-05 |     15 |
  +------------+--------+
  
  Time series 2 example
  +------------+--------+
  | Date       |  Value |
  +------------+--------+
  | 2014-03-01 |     21 |
  | 2014-03-02 |     22 |
  | 2014-03-05 |     25 |
  | 2014-03-06 |     26 |
  +------------+--------+
  
  Intermediate result desired
  +------------+----------------------+---------------------+
  | Date       |  Time series 1 value | Time series 2 value |
  +------------+----------------------+---------------------+
  | 2014-03-01 |                   11 |                  21 |
  | 2014-03-02 |                   12 |                  22 |
  | 2014-03-03 |                   13 |                 NaN |
  | 2014-03-04 |                   14 |                 NaN |
  | 2014-03-05 |                   15 |                  25 |
  | 2014-03-06 |                  NaN |                  26 |
  +------------+----------------------+---------------------+
  
  Final result desired
  +------------+----------------------+---------------------+
  | Date       |  Time series 1 value | Time series 2 value |
  +------------+----------------------+---------------------+
  | 2014-03-01 |                   11 |                  21 |
  | 2014-03-02 |                   12 |                  22 |
  | 2014-03-05 |                   15 |                  25 |
  +------------+----------------------+---------------------+
  </code></pre>
  
  <p>MATLAB's and Octave's intersect function can return the index positions of the intersected set elements, as well as the intersection set, like so (<a href="http://www.mathworks.com.au/help/matlab/ref/intersect.html#btcnv0p-11" rel="nofollow">MATLAB reference</a> : <a href="http://octave.sourceforge.net/octave/function/intersect.html" rel="nofollow">Octave reference</a>):</p>
  
  <pre><code>[C a_idx b_idx] = intersect(a_vector, b_vector)
  </code></pre>
  
  <p>While Julia's intersect function would only return the the equivalent of <code>C</code> above from what I can tell (<a href="http://docs.julialang.org/en/release-0.1/stdlib/base/#Base.intersect" rel="nofollow">Julia reference</a>)</p>
  
  <pre><code>C = intersect(a_vector, b_vector)
  </code></pre>
  
  <p>How can I acheive this concatenation of two time series in Julia where only those dates that both have data are included in the final result?</p>
  
  <p>I've played around with <code>findin()</code> and I can get some indices, but perhaps the way I've written MATLAB/Ocatave code in the past can't/shouldn't be replicated in Julia, so I'm interested in the best way to get the final time series result in the most accurate and efficient way possible using Julia.</p>
  
  <p>(The time series examples given of course are only to clarify what I'm trying to achieve, the data can be millions to billions in the 1st dimension)</p>