Hi there,
I would like to calculate ratio of NN (total markers/ total NN) from different groups (here 6 sample A and B-groups) in R. It must be easy but I couldn't any example online.
I have found some similar answer but as a newbie to R, I couldn't annotate the code. https://stackoverflow.com/questions/48555851/adding-a-row-for-the-ratio-of-two-variables
A1 A2 A3 A4 A5 A6 B1 B2 B3 B4 B5 B6
M1 CC CC AC AA CC CC CC AA AC CC CC CC
M2 NN AA AA AC AA AA AA AA AA AA AA AA
M3 AA AA NN NN AA AA GG NN GG GG NN NN
M4 NN NN NN AA AA NN AA AA AA AA NN NN
expected output
A1 A2 A3 A4 A5 A6 B1 B2 B3 B4 B5 B6 A-ratio B-ratio A+B-ratio
M1 CC CC AC AA CC CC CC AA AC CC CC CC - - -
M2 NN AA AA AC AA AA AA AA AA AA AA AA 0 - 11
M3 AA AA NN NN AA AA GG NN GG GG NN NN 1.5 0.7 1.4
M4 NN NN NN AA AA NN AA AA AA AA NN NN 0 4 1.0
Thanks for your help.
I don't understand what A-ratio, B-ratio, A+B-ratio are supposed to represent. Can you spell out how you arrived at the values in the last three columns of the second row?