Hello,
With this dataset I made this geom_col but I would like to add as a secondary axis (on the left) my depths with geom_line to have points corresponding to each of the depths and also a line that connects all the points and therefore crosses the whole chart !
How can I do ?
df <- tribble(
~zone, ~type, ~station, ~species, ~number, ~depth
'A1', 'Adult', 1, 'Atlanticus', 2, 200,
'A1', 'Adult', 1, 'Olrikii', 1, 450,
'A1', 'Larvae', 2, 'Medius', 5, 345,
'A2', 'Larvae', 1, 'Glacialis', 7, 269,
'A2', 'Larvae', 2, 'Unidentified', 3, 405,
'A2', 'Adult', 2, 'Glacialis', 2, 380,
'A2', 'Larvae', 2, 'Medius', 4, 310,
'A3', 'Zoo', 1, 'Capilatta', 17, 290,
'A3', 'Adult', 3, 'Olrikii', 1, 410
)
df %>% group_by(zone) %>% mutate(Percent = 100 * number/sum(number)) %>%
ggplot(aes(zone, y = Percent, fill = species)) + geom_col(position = "dodge")