How to create a grouped bar chart in R with ggplot2's geom_col and position_dodge functions (CC107)

preview_player
Показать описание
A grouped bar chart plot can be an effective way to represent the variation across a continuous variable for multiple levels of two categorical variables. These plots can be made in R using the geom_col and position_dodge functions from the ggplot2 R package. Watch this episode where Pat will demonstrate how to create barplots. Although these are superior to stacked barcharts, there are still problems with barcharts that he will discuss in this episode of Code Club.

Do you have a figure that you would like to receive a critique or help improving? Let me know and I'd be happy to arrange a guest appearance!

You can also find complete tutorials for learning R with the tidyverse using...

0:00 Introduction
5:56 Creating a grouped barchart
8:38 Deciding Which variable to group by on x-axis
14:09 Changing the plot to use genus data
22:57 Critique and Recap
Рекомендации по теме
Комментарии
Автор

Anyone have anything to report back on their conversation with their PI or colleagues about using stacked vs grouped barcharts? Let us know what points were brought up!

Riffomonas
Автор

At first broom::glance these videos may seem basic, but several of my peers sometimes struggle with formatting their graphs and this video can be really helpful in brushing up on the basics.

sitendugoswami
Автор

This is the best video. I always appreciate your teaching approach and explanation. please release videos on LULC or land use Land Cover Classification by using R. Thank You!

getnetengdaw
Автор

Thank you for these very helpful videos!

jagdishthakur
Автор

Hi. I was hoping to work in parallel with your video so I can learn how to apply this to my data, but am having trouble finding where the code is in the GitHub folder. Can you please tell me how to find it? Thanks.

alliejean
Автор

Hi, I have one question. How can we arrange the bars' position under the same variable. What if I want to swtich Healthy to the right, and Diarrhea C. to the left? Thank you!

ruiwang
Автор

How would I be able to change the order of the bars and the legend? Say for example, if I wanted to make "Healthy" the 3rd one down on the legend, and the third one in each group of columns? Like if I wanted the order to be Diarrhea, C. difficile positive; Diarrhea, C. difficile negative; Healthy?

christophernavarrete
Автор

Hi! thank you for a great video, very helpful. I tried to add errorbars, but the errorbars center in the middle as though it is still a stacked bar chart. Is there a way of separating the errorbars and get them to center over their respective bar? I hope my question makes sense.

augustdinsen
Автор

My grouped bar chart doesnt keep the order from column to column. I have searched everywhere and I still dont have a solution. Do you know what could be the problem ?

guilhermesoares
Автор

Thank you for the video. I just have a question regarding saving the output graph. I used R markdown and set the graph dimension, fig.height = 8, fig.width = 6 for example, to have a good size of graph. Of course, the font size are also adjusted in function of the dimension of the graph. However, when I used ggsave. The font size become much smaller, almost every thing. Could you give me some hints with that issue. I appreciate your help. Thank you!

minhtrungdang
Автор

thanks, this is very helpful. Can I kindly request you if you could please put the details on how we can add ANOVA statistical significance as numerical or as asterisks above each grouped stacked bar.

KN-txsd
Автор

this video was so helpful! I have a question a made a facet graph with 16 small graphs, is there a way to separate them onto 16 different pages for easier viewing?

tylerminenube
Автор

Hi, your videos were very helpful to make figures with my own data. I made the relative abundance plot with geom_col but the plot were stacked by alphabetic order. Is there a way to reorder the stacked plot by legend order?

ehtae
Автор

This guy is just doing these videos because he is trying to show off his knowledge.

richardsmith