R: How to plot rpivotTable or dcast table with summarised column in between same as excel for reporting of continues data.
Check attached screenshot and data set, tried different way to add summarised column in dcast and rpivottable but not getting it.
Sample Data set be like.
Buyer year_month Late_Days
A 2018-01 0 or Early
B 2018-01 >=5
C 2018-02 >=10
A 2018-04 0 or Early
A 2018-03 >=5
B 2018-03 >=10
C 2018-05 0 or Early
A 2018-06 >=5
B 2018-07 >=10
A 2018-11 0 or Early
B 2018-11 >=5
A 2019-01 >=10
B 2019-01 0 or Early
A 2019-01 >=5
A 2019-02 >=10
Result of dput(DF)
year_month("12-2019", "01-2020", "01-2020", "06-2018", "08-2018", "09-2018", "12-2018", "03-2019",
"11-2016", "11-2016", "04-2019", "07-2017", "08-2017", "09-2017", "10-2017", "11-2017", "12-2017",
"01-2018", "02-2018","03-2018", "04-2018", "05-2018", "06-2018", "07-2018", "08-2018", "09-2018",
"07-2017", "08-2017", "09-2017", "10-2017", "11-2017", "12-2017", "01-2018", "02-2018","03-2018",
"04-2018", "05-2018", "06-2018", "07-2018", "08-2018", "09-2018","08-2017", "09-2017", "03-2018",
"04-2019") Late_Days = c("<=20", "<=10", "<=5", "<=20", "0 or early", "0 or early", "0 or early",
"0 or early", "0 or early", "<=30", "0 or early", "<=10", "<=5",
"0 or early", "0 or early", "0 or early", ">30", "<=20", "<=20",
"<=20", "<=20", ">30", "<=20", "<=5", "<=5", "<=5", "<=5", "<=10",
"<=10", ">30", "<=5", "0 or early", "<=5", "0 or early", "0 or early",
"0 or early", "<=10", "<=5", "0 or early", "0 or early", "0 or early"
"<=20", "<=5", "<=5", "<=5")Buyer = c(
"C", "D", "D", "D", "D", "A", "D", "A", "A", "C", "A", "A", "A", "A", "A",
"A", "A", "A", "A", "A", "A", "A", "A", "C", "C", "A", "C", "A", "A", "A",
"A", "B", "B", "A", "A", "B", "B", "B", "A", "A", "C", "C", "A", "A", "A",
)row.names = c(1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 20L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L)
Code i tried
datatable(dcast(inventory, Buyer ~ year_month), filter = 'top')
Check the screenshot of excel report. is it possible to generate in R.