From 27ebac51f57200ff93ed719671ae1760061a2d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a?= Date: Fri, 26 Jun 2026 11:37:47 +0200 Subject: [PATCH] =?UTF-8?q?[=C3=A9Cow]=20correctif=20bloc=20taureaux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/project/ecow_calculations.R | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/R/project/ecow_calculations.R b/R/project/ecow_calculations.R index b002074..c2db516 100755 --- a/R/project/ecow_calculations.R +++ b/R/project/ecow_calculations.R @@ -281,11 +281,11 @@ calcul_ecow_by_chep <- function(cheptel, step = 3) { summarise( utilgen = round(mean(rangVelageMipg == 1, na.rm = TRUE) * 100, 1), prol = round(n() / n_distinct(dateNaiss, numeroMipg) * 100, 1), - mort = round(mean(mortsev == "O" | mortnat == "O") * 100, 1), + mort = round((sum(mortsev == "O" | mortnat == "O", na.rm = TRUE)) / n() * 100, 1), txrepros = round( sum(repro == "O", na.rm = TRUE) / - sum(is.na(mortsev) | is.na(mortnat)) * 100, 1 + sum(is.na(mortsev) & is.na(mortnat)) * 100, 1 ), nbpp = sum(NBPRODIPG, na.rm = TRUE), @@ -340,7 +340,7 @@ calcul_ecow_by_chep <- function(cheptel, step = 3) { group_by(pereGenetique) %>% summarise( nbfillesact_avecprod = sum(NBPRODIPG > 0, na.rm = TRUE), - pctfillesact_avecprod = round(nbfillesact_avecprod / n() * 100, 1), + #pctfillesact_avecprod = round(nbfillesact_avecprod / nbfilles_avecprod * 100, 1), isu_fillesact = 0, age_sort_fillesact = ifelse(n() >= 3, round(mean(age_years, na.rm = TRUE), 1), NA), @@ -364,12 +364,16 @@ calcul_ecow_by_chep <- function(cheptel, step = 3) { .groups = "drop" ) - inventaire <- bind_rows(cheptel_ecow$vaches, cheptel_ecow$produits) - inventaire <- add_data_ecow(inventaire, czhbc) - stats_filles_renouv <- inventaire %>% + grp_filles_et_act <- stats_filles %>% + dplyr::left_join(stats_filles_act, by = "pereGenetique") %>% + mutate( + pctfillesact_avecprod = round( nbfillesact_avecprod / nbfilles_avecprod * 100, 1 ) + ) + + stats_filles_renouv <- produits_cheptel %>% filter( sexe == "2", - NBPRODIPG == 0 + nbFinGestation == 0 # TODO valider avec Lauréna que c'est bien ce champ là qu'on veut ) %>% group_by(pereGenetique) %>% summarise( @@ -379,8 +383,7 @@ calcul_ecow_by_chep <- function(cheptel, step = 3) { stats_taureaux <- stats_peres %>% dplyr::left_join(stats_prod_directe, by = "pereGenetique") %>% - dplyr::left_join(stats_filles, by = "pereGenetique") %>% - dplyr::left_join(stats_filles_act, by = "pereGenetique") %>% + dplyr::left_join(grp_filles_et_act, by = "pereGenetique") %>% dplyr::left_join(stats_filles_renouv, by = "pereGenetique") %>% dplyr::left_join(taureaux, by = "pereGenetique")