0

I am completing the last course in the Google Data Analytics Certification program and have been tasked with completing a case study. We were directed to use specific sets of data for analysis. I am trying to create a bar plot that shows the difference in user participation.

ggplot() +
  geom_bar(data = sleepDay_merged, aes(x = n_unique(Id))) + 
  geom_bar(data = weightLogInfo_merged, aes(x = n_unique(Id))) +
  geom_bar(data = dailyActivity_merged, aes(x = n_unique(dailyActivity_merged$Id))) +
  labs(title = 'Difference In User Data', subtitle = "Sleep Vs. Weight Vs. Daily Activity")

What I am currently having trouble with is getting rid of the default Y axis label that reads "count". I would also like to rename the X axis to clean up the plot more. I would also like to create individual colors for each bar along with a legend. I am VERY new to R and just keep hitting road blocks. I would appreciate any guidance whatsover.

Thanks, Saiyid

Martin Gal
  • 16,640
  • 5
  • 21
  • 39
whosane
  • 1
  • 2
  • 2
    `labs(y = "My New Title", x = "Renamed X axis")` should work. – Martin Gal Oct 20 '21 at 21:56
  • Thank you! I just tried theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) to make it cleaner. I am now trying to color each bar and create a legend. Any more assistance will even more appreciated. Thank you, Martin. – whosane Oct 20 '21 at 22:06
  • 1
    It would be easier, if you share a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – Martin Gal Oct 20 '21 at 22:18
  • ggplot() + geom_bar(data = sleepDay_merged, aes(x = n_unique(Id))) + geom_bar(data = weightLogInfo_merged, aes(x = n_unique(Id))) + geom_bar(data = dailyActivity_merged, aes(x = n_unique(dailyActivity_merged$Id))) + labs(title = 'Difference In User Data', subtitle = "Sleep Vs. Weight Vs. Daily Activity") + theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + annotate('text', x=25, y=850, label= "Daily Activity has the most user input") + annotate('text', x=12, y= 120, label= 'Weight has the least user input') – whosane Oct 20 '21 at 22:30
  • I am hoping that's what you mean. I apologize if it wasn't. That is the code I have so far. I am now trying to update the plot to add color to each bar and create a legend for it. Unfortunately, I will most likely have many more questions. Sorry in advance! – whosane Oct 20 '21 at 22:32
  • A reproducible example should include the data as well as the code necessary to encounter the problem. If you're completing some course for which the data is publicly available, it would help if you include how the data is read in, manipulated and plotted. If you have insufficient reputation to edit your question to include the necessary details, you could ask if someone would include these based on the comments. – teunbrand Oct 21 '21 at 00:39
  • Oh, ok. Sorry about that. They directed us to a notebook on kaggle. https://www.kaggle.com/arashnic/fitbit – whosane Oct 21 '21 at 03:56

0 Answers0