Hi
Does anyone know how to make a horizontal bar plot that is ordered descending by the numeric variable and puts NA values at the end.
So just like the example below but with the New species with NA Petal.Length on the bottom.
I am looking for a way to do this without manually specifying levels and also without changing the NA value to zero.
Any help would be gratefully received.
Thanks!!
library(dplyr)
library(ggplot2)
plot_data <- iris %>%
group_by(Species) %>%
summarise(Petal.Length = mean(Petal.Length)) %>%
add_row(Species = "New species") %>%
mutate(Species = forcats::fct_reorder(Species, Petal.Length))
ggplot(plot_data) +
geom_col(aes(Species, Petal.Length)) +
coord_flip()
