I am working with a very big dataset. It has yearly data, and I am creating the monthy average of a daily value. I have so many rows of different indicators, and the columns are the daily values of them. The problem is that, when a value is not valid, it is a 0, so when calculating the average, it is taken into account. How can I exclude it? is turning it into a NA the only way?
I have this chunk of code:
DF <- DF %>%
rowwise() %>%
mutate(montly_Average = mean(c(D01, D02, D03, D04, D05,
D06, D07, D08, D09, D10,
D11, D12, D13, D14, D15,
D16, D17, D18, D19, D20,
D21, D22, D23, D24, D25,
D26, D27, D28, D29, D30,
D31)))
I have about 70 variables, that is why I had to select the ones that interest me that way.