I have a dataset with a lot of NA but on the same row's are data which are important so I cannot remove the rows. I also cannot replace the NA with a 0 because i want to get an average. What can i do?
example of R script:
data_week1 <- data_calc %>%
dplyr::group_by(room, pen, block, treatment)%>%
dplyr::filter(week == '1')%>%
dplyr::summarise(adfi_week1 = sum(feedintake/7),
ph = mean(ph),
ds = mean(ds),
fecalscore = mean(fecalscore))
ADFI is measured every day while pH is measured once a week
Update: I tried the code below, but it's not working:
data_calc <- data_ruw %>%
dplyr::group_by(datum, afdeling, hok, blok, behandeling) %>%
dplyr::mutate(voerinname_ochtend_kgbrij = voerinname_ochtend_kgbrij*3,
voerinname_middag_kgbrij = voerinname_middag_kgbrij*3,
voeropname_dag_brij = voerinname_ochtend_kgbrij + voerinname_middag_kgbrij - voer_uit_ochtend - voer_uit_middag, na.rm = TRUE,
voeropname_kgdroogvoer = voeropname_dag_brij * 0.25/0.88, na.rm = TRUE,
mest_ds = mest_gewicht_in - mest_gewicht_uit - 5.6 - 7, na.rm = TRUE)