Hello,
Looking to remove products that have all zeros in any given row. For example data below, BW and FX should be removed as they have all zeros.
My dataset contains several of these products and thus, looking to remove them efficiently.
Thanks for the help!
df <- data.frame(
stringsAsFactors = FALSE,
Date = c("2017-01-01",
"2017-02-01",
"2017-03-01","2017-04-01",
"2017-05-01","2017-06-01",
"2017-07-01",
"2017-08-01","2017-09-01",
"2017-10-01","2017-11-01",
"2017-12-01","2018-01-01",
"2018-02-01",
"2018-03-01","2018-04-01",
"2018-05-01","2018-06-01",
"2018-07-01",
"2018-08-01","2018-09-01",
"2018-10-01","2018-11-01",
"2018-12-01","2017-01-01",
"2017-02-01",
"2017-03-01","2017-04-01",
"2017-05-01","2017-06-01",
"2017-07-01",
"2017-08-01","2017-09-01",
"2017-10-01","2017-11-01",
"2017-12-01","2018-01-01",
"2018-02-01",
"2018-03-01","2018-04-01",
"2018-05-01","2018-06-01",
"2018-07-01",
"2018-08-01","2018-09-01",
"2018-10-01","2018-11-01",
"2018-12-01","2017-01-01",
"2017-02-01",
"2017-03-01","2017-04-01",
"2017-05-01","2017-06-01",
"2017-07-01",
"2017-08-01","2017-09-01",
"2017-10-01","2017-11-01",
"2017-12-01","2018-01-01",
"2018-02-01",
"2018-03-01","2018-04-01",
"2018-05-01","2018-06-01",
"2018-07-01",
"2018-08-01","2018-09-01",
"2018-10-01","2018-11-01",
"2018-12-01"),
Product = c("TS","TS",
"TS","TS","TS","TS",
"TS","TS","TS","TS",
"TS","TS","TS","TS",
"TS","TS","TS","TS",
"TS","TS","TS","TS",
"TS","TS","BW","BW",
"BW","BW","BW","BW",
"BW","BW","BW","BW",
"BW","BW","BW","BW",
"BW","BW","BW","BW",
"BW","BW","BW","BW",
"BW","BW","FX","FX",
"FX","FX","FX","FX",
"FX","FX","FX","FX",
"FX","FX","FX","FX",
"FX","FX","FX","FX",
"FX","FX","FX","FX",
"FX","FX"),
Sales = c(0,0,0,0,0,
596,3476,4457,4666,
5967,10177,9475,6056,
4302,6134,6676,8440,
10171,9182,8154,
6006,5992,9028,7330,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0)
)
df <- df%>%
mutate(Date = ymd(Date))