This is how I want the plot to look:
flights$carrier[seq(1, length(flights$carrier), 20)] <- NA
flights %>%
count(carrier) %>%
top_n(10) %>%
ggplot() +
geom_col(aes(x = reorder(carrier, n), y = n))
But I'd like to rename the NA as "Unknown". Whenever I do, the position of the bar changes:
flights %>%
count(carrier) %>%
mutate(
carrier = coalesce(carrier, 'Unknown')
) %>%
top_n(10) %>%
ggplot() +
geom_col(aes(x = reorder(carrier, n), y = n))
I've tried several different things, including attempting to more or less manually relabel with scale_x_discrete
and others. Even if that worked, it wouldn't scale well.