title: Comparing two vectors in an if statement
body: <p>I want put stop condition inside a function. The condition is that if first and second elements should match perfectly in order and length. </p>
  
  <pre><code>A &lt;- c("A", "B", "C", "D")
  B &lt;- A
  C &lt;- c("A", "C", "C", "E")
  
  &gt; A == B
  [1] TRUE TRUE TRUE TRUE
  </code></pre>
  
  <p>This is good situation to go forward </p>
  
  <pre><code>&gt; A == C
  
  [1]  TRUE  FALSE TRUE FALSE
  </code></pre>
  
  <p>Since there is one false this condition to stop and output that the condition doesnot hold at 2 and 4 th column. </p>
  
  <pre><code>if (A != B) {
             stop("error the A and B does not match at column 2 and 4"} else {
              cat ("I am fine") 
                  }
  Warning message:
  In if (A != B) (stop("error 1")) :
    the condition has length &gt; 1 and only the first element will be used
  </code></pre>
  
  <p>Am I missing something obvious ? Also I can output where error positions are ? </p>