如下所示的数据框df
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)
对于每个月,需要计算qty
和数量份额作为月份总数量的百分比,用于各种价格范围,例如低于500,500&lt; = price&lt; 750,750&lt; =价格&lt; 1000,1000&lt; = price&lt; 1250,1250&lt; = price&lt; 1500,1500以上