If I have a dataframe with samples as columns and categorical values [A, H] as rows:
Samp1 Samp2 Samp3 Samp4 Samp5
A 17.80000 56.000 0.2380 24.0000 31.700
B 29.80000 21.000 21.5000 59.7000 43.100
C 2.09000 7.450 0.0000 1.8800 4.670
D 0.00228 6.850 0.0159 4.6300 10.100
E 19.40000 2.860 11.1000 0.8160 1.220
F 10.60000 4.390 30.9000 4.5600 7.730
G 9.87000 0.501 4.2100 0.8100 0.176
H 0.10000 0.106 10.6000 1.1700 0.104
How can I collapse cell counts < threshold (e.g. 10) into an "X" category (that is putting to zero the cell and adding a cell with the sum of all under-threshold cells), like:
Samp1 Samp2 Samp3 Samp4 Samp5
A 17.80000 56.000 0.0000 24.0000 31.700
B 29.80000 21.000 21.5000 59.7000 43.100
C 0.00000 7.450 0.0000 0.0000 0.000
D 0.00000 6.850 0.0159 0.0000 10.100
E 19.40000 2.860 11.1000 0.0000 0.000
F 10.60000 4.390 30.9000 0.0000 0.000
G 0.00000 0.501 0.0000 0.0000 0.000
H 0.00000 0.106 10.6000 0.0000 0.000
X 12.06200 22.157 4.3200 13.8660 13.900 <--
many thanks, glad to clarify if this is not clear.