I have a huge panel data set with daily data. I would like to remove all days for which I have missing data of more than 25% of the observations in the column "Size".
I created the following data to show how my real data looks like:
structure(list(Product = c("A", "A", "A", "A", "A", "A", "A",
"A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "C", "C",
"C", "C", "C", "C", "C", "C", "C"), Date = c("01.09.2018", "02.09.2018",
"03.09.2018", "04.09.2018", "05.09.2018", "11.11.2020", "12.11.2020",
"13.11.2020", "14.11.2020", "01.09.2018", "02.09.2018", "03.09.2018",
"04.09.2018", "05.09.2018", "11.11.2020", "12.11.2020", "13.11.2020",
"14.11.2020", "01.09.2018", "02.09.2018", "03.09.2018", "04.09.2018",
"05.09.2018", "11.11.2020", "12.11.2020", "13.11.2020", "14.11.2020"
), Size = c(10L, 9L, NA, 3L, 4L, 5L, 3L, NA, 6L, 7L, 4L, NA,
4L, 6L, 6L, 4L, 6L, 7L, 3L, 4L, NA, 2L, 4L, NA, 7L, 7L, 5L)), class = "data.frame", row.names = c(NA,
-27L))
I already tried the following but I got stock on how to continue with the code:
Data %>% summarize(group_by(Date), NoData=(is.na(Size))
Then I got the error that I cannot use group_by for an object of the class "Date". Further, I don't know how I can automatically remove the days where I have more than 25% of missing values in the column "Size".
Could anyone help me here with the code that works for my problem?
I appreciate your help.