1

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.

Rike
  • 21
  • 3
  • 1
    I think you have a typo in the geom_bar line, should close the `aes` parenthesis sooner: `geom_bar(aes(fill=member_casual), stat="identity", position= "dodge")`, since those other bits are parameters you want to send to `geom_bar` and not aesthetic mappings that belong inside `aes()` – Jon Spring May 05 '22 at 22:57

1 Answers1

1

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!

Rike
  • 21
  • 3