How can I rename the header in R, based on information from the current header?
My df look likes:
header: (index; d__Bacteria.p__Actinobacteriota.c__Actinobacteria ; d__Bacteria.p__Bacteroidota.c__Bacteroidia )
Row 1: (BF13A; 0; 14572)
Row 2: (BF13B; 0; 24215)
etc
I want to rename the columns with taxonomy information (d__Bacteria.) to only have the information after c__
header: (index; Actinobacteria ; Bacteroidia )
Row 1: (BF13A; 0; 14572)
Row 2: (BF13B; 0; 24215)
ect.
Btw I have more columns than two with taxonomic information, so the solution such work on bigger df as well.
You can rename the columns using
tidyverse. Something like below,This can also be done using base functions
Instead of setting the new column names, you can modify the old names like this