I would like to perform a geom_bar of the percentage of species per station.
However I only have abundance per station.
How can I go about getting the percentage that each species represents per station (percentage in relation to the total abundance per station and not in relation to the whole dataset)
In this example, station A1 has a total abundance of 8 and I would like to have a new percentage column where there will be for Atlanticus 0.25 [(2/8) * 100].
df <- tribble( ~zone, ~type, ~station, ~species, ~number, 'A1', 'Adult', 1, 'Atlanticus', 2, 'A1', 'Adult', 1, 'Olrikii', 1, 'A1', 'Larvae', 2, 'Medius', 5, 'A2', 'Larvae', 1, 'Glacialis', 7, 'A2', 'Larvae', 2, 'Unidentified', 3, 'A2', 'Adult', 2, 'Glacialis', 2, 'A2', 'Larvae', 2, 'Medius', 4, 'A3', 'Zoo', 1, 'Capilatta', 17, 'A3', 'Adult', 3, 'Olrikii', 1 )
The ideal would be to do this transformation directly by coding the ggplot but if you have to modify the dataset before it does not matter
Thanks very much