Entering edit mode
2.2 years ago
bhbh
▴
30
Hello to everyone!
Can everyone halps me in R code to aggregate this dataframe abundance based on samples. Then to put in order dataframe based on abundance of "others", so if in the human sample "others" are more then human sample written bacteria, arrange it in the bottom of dataframe. And compute the same for other samples. This is the part of my dataframe:
samples | abundance | bacteria
human | 0.0010928962 | Lactobacillus
human | 0.0109282828 | Bifidobacterium
human | 0.0001366120 | others
mice | 0.0003005464 | Lactobacillus
mice | 0.000609838 | Lactobacillus
mice | 0.0004918033 | others
rat | 0.000309838 | Bifidobacterium
human | 0.0861612022 | Bifidobacterium
rat | 0.1801775956 | Bifidobacterium
mice | 0.1801775956 | Bifidobacterium
rat | 0.0011110220 | Lactobacillus
You can for example use aggregate in base R, the data.table package or tidyverse/summarise for that problem.