Convert abundance data into percentage data.
convert2percentages(df, col2convert = 2:ncol(df))
The dataframe containing the data to convert.
A vector of the columns to convert. Default is all the columns but the first, which contains an age, a depth or a sampleID.
A vector of unique taxonIDs.
df <- data.frame(matrix(1:25, ncol = 5))
colnames(df) <- paste(rep("col", 5), 1:5, sep = "")
convert2percentages(df)
#> col1 col2 col3 col4 col5
#> 1 1 11.11111 20.37037 29.62963 38.88889
#> 2 2 12.06897 20.68966 29.31034 37.93103
#> 3 3 12.90323 20.96774 29.03226 37.09677
#> 4 4 13.63636 21.21212 28.78788 36.36364
#> 5 5 14.28571 21.42857 28.57143 35.71429
convert2percentages(df, col2convert = 3:5)
#> col1 col2 col3 col4 col5
#> 1 1 6 22.91667 33.33333 43.75000
#> 2 2 7 23.52941 33.33333 43.13725
#> 3 3 8 24.07407 33.33333 42.59259
#> 4 4 9 24.56140 33.33333 42.10526
#> 5 5 10 25.00000 33.33333 41.66667