Rike
Rike

Reputation: 21

Make a grouped barplot from count value in ggplot?

Good day everyone, I'm working with a fairly large dataset and am attempting to make a grouped barplot using ggplot2 in R. I'm struggling trying to divide my plot. I want to get the count for each month by the different types of members.

So far this is my code

bike_rides %>%  
  group_by(member_casual, month_of_use) %>%  
  summarize(Count = n()) %>% 
  ggplot(aes(x=month_of_use, y=Count)) + 
  geom_bar(aes(fill=member_casual, stat="identity", position= "dodge")) 

This output produces this error: Screenshot

Farily new to R so please be patient with me, any feedback is greatly appreciated.

Thank you.

Upvotes: 1

Views: 2608

Answers (1)

Rike
Rike

Reputation: 21

Was able to answer my question thanks to @Jon Spring, closing the aes sooner made the difference!

bike_rides %>%  
  group_by(member_casual, month_of_use) %>%  
  summarize(Count = n()) %>% 
  ggplot(aes(x=month_of_use, y=Count, fill=member_casual)) + 
  geom_bar(stat='identity', position= "dodge")

New Graph

Practice makes perfect!

Upvotes: 1

Related Questions