with a dataframe df
like below
df <- read.table(textConnection("
month model price qty
jan A 900 15000
jan B 600 30000
jan C 1200 12000
jan A 850 1200
feb A 750 20000
feb C 1500 8000
feb C 1450 4000
"), header = TRUE)
for each month, need to compute the qty
and qty share as a percentage of total qty for the month for various price bands like below 500, 500 <= price < 750, 750 <= price < 1000, 1000 <= price < 1250 , 1250 <= price < 1500, above 1500