> gender %>% arrange(desc(age))
# A tibble: 18 x 3
age sex pop
<chr> <chr> <dbl>
1 62+ Female 51
2 62+ Male 167
3 55-61 Female 98
4 55-61 Male 283
5 5-12 Female 93
6 5-12 Male 87
7 45-54 Female 160
8 45-54 Male 346
9 35-44 Female 257
10 35-44 Male 315
11 25-34 Female 207
12 25-34 Male 285
13 18-24 Female 103
14 18-24 Male 72
15 13-17 Female 37
16 13-17 Male 34
17 0-4 Female 63
18 0-4 Male 105
I cant figure out why "5-12" is not being ordered correctly.
Here is my code
ggplot(data = gender,
mapping = aes(x = age, y = ifelse(test = sex == "Male", yes = -pop, no = pop),
fill = sex, )) +
geom_col(col = "black") +
coord_flip() +
scale_y_continuous(labels = abs, limits = max(gender$pop) * c(-1,1)) +
labs(y = "Population") +
labs(title="Age Distribution by Male & Female Genders",
#subtitle="Point-In-Time Count 2011-2020",
x="Age Range",
y="Individuals Counted",
fill = "Gender") +
scale_fill_brewer(palette = "Set1")
Currently my x-axis has only 3 labels c(200,0,200).
How can I do c(300,200,100,0,100,200,300)
Thank you