How to solve The condition has length > 1 and only the first element will be used in R : <p>When I type these code ,</p>

<pre><code>z&lt;-NULL
for(i in unique(A$KCL_ID)){
  RESULT&lt;-A[A$KCL_ID==i,]
    if(RESULT$DAYS==min(RESULT$DAYS)){
      RESULT$DATE&lt;-"closest"
    }else{RESULT$DATE&lt;-RESULT$BMIextraction}
z&lt;-rbind(z,RESULT)
  }
</code></pre>

<p>I get some error message like this:</p>

<pre><code>Error in charToDate(x) : 
character string is not in a standard unambiguous format
In addition: Warning messages:
1: In if (RESULT$DAYS == min(RESULT$DAYS)) { :
  the condition has length &gt; 1 and only the first element will be used
2: In if (RESULT$DAYS == min(RESULT$DAYS)) { :
  the condition has length &gt; 1 and only the first element will be used
3: In if (RESULT$DAYS == min(RESULT$DAYS)) { :
  the condition has length &gt; 1 and only the first element will be used
4: In if (RESULT$DAYS == min(RESULT$DAYS)) { :
  the condition has length &gt; 1 and only the first element will be used
</code></pre>

<p>How can I resolve this question?</p>
