→ celestialgod: dcast.data.table有 drop=FALSE 11/11 23:37
推 celestialgod: 記得要取成factor就好 11/11 23:38
→ thephone: 好的 我試試看 thx 11/12 10:01
想進一步分別計算
消費者在不同區間下消費金額佔整體比例
如下
消費者 below100 100 200 300 400 500 600 700 ...30000
A 0 0.2 0.2 0 0.6 0 0 0 0
B 0 0 0 0 0.5 0 0.5 0 0
C 0 0 0.66 0.33 0 0 0 0 0
有建議使用的方式嗎?
謝謝
※ 編輯: thephone (122.147.21.174), 11/12/2015 23:41:00
→ celestialgod: sweep(as.matrix(dd), 2, colSums(dd), '/') 11/12 23:42
→ celestialgod: 大概長這樣,untested 11/12 23:42
→ thephone: 學到了sweep 謝謝c大 11/13 10:48
→ thephone: 後來看到prop.table也可以使用 11/18 13:59