I have this data set:
bizdev company date category
<chr> <chr> <date> <chr>
1 Jerry Harding Jones, Figueroa and Moon 2020-04-06 Mid-tier
2 Steve Vargas Stanley, Porter and Mccoy 2020-04-24 Indie
3 Steve Vargas Gardner and Sons 2020-04-19 Indie
4 Jerry Harding Parks-Chen 2020-04-11 Indie
5 Jerry Harding Bond Group 2020-04-06 Indie
6 David Burton Lopez-Johnson 2020-05-07 Enterprise
I try to produce a bar chart after transformation.
consol <- df %>% mutate(meeting_month = as_factor(month(date, abbr = TRUE, label = TRUE)), .keep = 'unused') %>%
group_by(bizdev, category, meeting_month) %>% summarise(total_meeting = n())
# Groups: bizdev, category [22]
bizdev category meeting_month total_meeting
<chr> <chr> <ord> <int>
1 Bobby Adams Enterprise Apr 2
2 Bobby Adams Indie Mar 12
3 Bobby Adams Indie Apr 13
4 Bobby Adams Indie May 12
5 Bobby Adams Mid-tier Mar 6
6 Bobby Adams Mid-tier Apr 6
7 Bobby Adams Mid-tier May 3
8 David Burton Enterprise May 2
9 David Burton Indie Mar 30
10 David Burton Indie Apr 31
y-axis of bar chart is re-arrange by the value of x-axis with code below:
consol %>% ggplot(aes(x = total_meeting, y = reorder(bizdev, -total_meeting), fill = category))
+ geom_bar(stat="identity")
+ theme_classic()
Value at the Y-axis isn’t fully order from lowest to highest. Notice ‘Steve Vargas’ recorded higher total_meeting than ‘Joel English’. The position isn’t right.
Read more here: Source link