J'ai construit la fonction suivante:
DATE=function(r,s,t){if(r %in% Statut & s<=DATE_CLOTURE) {max(s,DATE_OUVERTURE)}else{min(max(DATE_OUVERTURE,t),DATE_CLOTURE)}}
où
1 2 3
| Statut=c("Resi","Dcs","Rac","Ec","Rad","Ren")
DATE_CLOTURE="31/12/2017"
DATE_OUVERTURE="30/06/2008" |
Et je voudrais calculer DATE(bdd$STATUT_CONTRAT,bdd$DATE_STAtut[i],bdd$DT_FIN_C[i]) pour toutes les lignes sans utiliser la boucle for
J'ai essayé ça:
DATE(bdd$STATUT_CONTRAT,bdd$DATE_STAtut,bdd$DT_FIN_C)
Le message d'erreur suivant s'affiche :
Warning message:
In if (r %in% Statut & s <= DATE_CLOTURE) { :
the condition has length > 1 and only the first element will be used
Merci de m'aider pour ceux qui pensent avoir une idée favorable.
D'avance je vous remercie
Partager