vendredi 6 avril 2018

How to solve The condition has length > 1 and only the first element will be used in R

When I type these code ,

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

I get some error message like this:

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 > 1 and only the first element will be used
2: In if (RESULT$DAYS == min(RESULT$DAYS)) { :
  the condition has length > 1 and only the first element will be used
3: In if (RESULT$DAYS == min(RESULT$DAYS)) { :
  the condition has length > 1 and only the first element will be used
4: In if (RESULT$DAYS == min(RESULT$DAYS)) { :
  the condition has length > 1 and only the first element will be used

How can I resolve this question?

Aucun commentaire:

Enregistrer un commentaire