I have data.tableone that looks like this:
x, y, sum(count)
1, 1, 3
1, 2, 7
1, 3, 8
2, 1, 4
2, 2, 3
2, 3, 10
Etc. He was attached to xand y, and I did sumin the column count. I would like to divide it into percentages by x values, so that it becomes:
x, y, percentage(counts)
1, 1, 16.7
1, 2, 38.9
1, 3, 44.4
2, 1, 23.5
2, 2, 17.6
2, 3, 58.8
Thus, the total percentage for xis 100%. I do this with a package data.table. Thank you in advance for your help.