I have a DT with multiple columns and I need to give a condition in ifelse and do the calculations accordingly. I want it to do count/sum(count) grouped by segment. Here is the DT
Segment Count Flag
A 23 Y
B 45 N
A 56 N
B 212 Y
I want the fourth column as count per total count of the segment based on the flag so the out put should look something like this. I am leaving blank for N flag because I have different column to compute but in the exact same manner, so I will be able to use the IFELSE condition.
Segment Count Flag Value
A 23 Y 23/66
B 45 N
A 56 N
B 212 Y 212/224
A 43 Y 43/66
B 12 Y 12/224
Any help is appreciated. Thanks!
Aucun commentaire:
Enregistrer un commentaire