How do I calculate the relative abundance for each variable for each sample in R? I would then like to create a new data frame with relative abundances in each column? I have 1000 variables (columns) and 500 samples (rows). I also have a total count for each sample.
ID var1 var2 var3 etc. total count
1 10 57 16 400
2 8 66 34 412
3 7 88 57 405
4 1 90 94 402
5 20 44 33 488
etc.
Expected output:
ID var1 var2 var3 etc.
1 0.03 0.14 0.04
2 0.02 0.16 0.08
etc