1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
listeNavires <- unique(tableCaptures$VESSEL_FK)
#pour chaque navire
for (k in 1:length(unique(tableCaptures$VESSEL_FK))){
#traitement des captures
navireTraite <- subset(tableCaptures,VESSEL_FK == listeNavires[k])
table2_TRAITEE <- subset(table2_SEQUENCES,VESSEL_FK == listeNavires[k])
#pour chaque jour
for (i in 1:length(navireTraite$OPERATION_FK)){
sequenceCapturestraitee <- tableCaptures[i,]
#correspondance entre Captures et table2 au niveau du jour
sequencestable2correspondantes <- subset(table2_TRAITEE, substr(sequenceCapturestraitee$START_DATE_TIME,1,10) == substr(START_DATE_TIME,1,10))
if (length(unique(sequencestable2correspondantes$END_DATE_TIME))>0){
listeSecteurs <- unique(sequencestable2correspondantes$SECT_LABEL)
for (j in 1:length(listeSecteurs)){
nbMetaMarees <- nbMetaMarees + 1
Captures_RAPPROCHE[nbMetaMarees,] <- sequenceCapturestraitee
Captures_RAPPROCHE[nbMetaMarees,]$SECTEUR_table2 <- listeSecteurs[j]
Captures_RAPPROCHE[nbMetaMarees,]$FISHING_TIME_table2 <- sum(sequencestable2correspondantes$FISHING_TIME[sequencestable2correspondantes$SECT_LABEL == listeSecteurs[j] ])
}
} else { #sequence Captures orpheline
nbSeqCapturesorphelines <- nbSeqCapturesorphelines + 1
Captures_ORPHELINE[nbSeqCapturesorphelines,] <- sequenceCapturestraitee
}
}
table2_ORPHELINES <- subset(table2_TRAITEE, ! substr(END_DATE_TIME,1,10) %in% unique(substr(navireTraite$END_DATE_TIME,1,10)))
table2_ORPHELINE_GLOBAL <- rbind(table2_ORPHELINE_GLOBAL,table2_ORPHELINES)
} |
Partager