I have a multivariate dataset of species relative abundance (%) in different samples. In this data frame I only have the most abundant species, so the total is not 100%.
My dataset looks like this but with much more species and samples:
species = c("Species1","Species2","Species3","Species4","Species5","Species6")
Sample1 = c(0.6,7.9,7.1,2.7,4.5,6.4)
Sample2 = c(1.8,0.3,0.9,3.3,1.7,9.8)
Sample3 = c(9.2,1,8,2.1,8,2.2)
Sample4 = c(6.1,1.3,9,5.3,5.5,6.2)
df = data.frame(species, Sample1, Sample2, Sample3, Sample4)
df
species Sample1 Sample2 Sample3 Sample4
1 Species1 0.6 1.8 9.2 6.1
2 Species2 7.9 0.3 1.0 1.3
3 Species3 7.1 0.9 8.0 9.0
4 Species4 2.7 3.3 2.1 5.3
5 Species5 4.5 1.7 8.0 5.5
6 Species6 6.4 9.8 2.2 6.2
But I would like to make a stacked bar plot where I also have the variable "Others" representing the percentage cover of all the rarest species together, calculated as 100 - sum of column
The result I would like is this:
species Sample1 Sample2 Sample3 Sample4
1 Species1 0.6 1.8 9.2 6.1
2 Species2 7.9 0.3 1.0 1.3
3 Species3 7.1 0.9 8.0 9.0
4 Species4 2.7 3.3 2.1 5.3
5 Species5 4.5 1.7 8.0 5.5
6 Species6 6.4 9.8 2.2 6.2
7 Others 70.8 82.2 69.5 66.6
How can I do? I've been searching for hours but I couldn't find a solution.

